pub trait OptionsSerializerImpl<'a>: OptionsImplLayout {
    type Option;

    // Required methods
    fn get_option_length(option: &Self::Option) -> usize;
    fn get_option_kind(option: &Self::Option) -> u8;
    fn serialize(data: &mut [u8], option: &Self::Option);
}
Expand description

An implementation of an options serializer.

OptionsSerializerImpl provides to functions to serialize fixed- and variable-length options. It is required in order to construct an OptionsSerializer.

Required Associated Types§

source

type Option

The input type to this serializer.

This is the analogous serializing version of Option in OptionsImpl. Options serialization expects an Iterator of objects of type Option.

Required Methods§

source

fn get_option_length(option: &Self::Option) -> usize

Returns the serialized length, in bytes, of the given option.

Implementers must return the length, in bytes, of the data* portion of the option field (not counting the type and length bytes). The internal machinery of options serialization takes care of aligning options to their OPTION_LEN_MULTIPLIER boundaries, adding padding bytes if necessary.

source

fn get_option_kind(option: &Self::Option) -> u8

Returns the wire value for this option kind.

source

fn serialize(data: &mut [u8], option: &Self::Option)

Serializes option into data.

Implementers must write the data portion of option into data (not the type or length octets, those are extracted through calls to get_option_kind and get_option_length, respectively). data is guaranteed to be long enough to fit option based on the value returned by get_option_length.

Object Safety§

This trait is not object safe.

Implementors§