packet::records::options

Trait OptionBuilder

Source
pub trait OptionBuilder {
    type Layout: OptionLayout;

    // Required methods
    fn serialized_len(&self) -> usize;
    fn option_kind(&self) -> <Self::Layout as OptionLayout>::KindLenField;
    fn serialize_into(&self, data: &mut [u8]);
}
Expand description

A builder capable of serializing an option.

Given O: OptionBuilder, an iterator of O can be used with a OptionSequenceBuilder to serialize a sequence of options.

Required Associated Types§

Source

type Layout: OptionLayout

Information about the option’s layout.

Required Methods§

Source

fn serialized_len(&self) -> usize

Returns the serialized length, in bytes, of self.

Implementers must return the length, in bytes, of the data* portion of the option field (not counting the kind 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 option_kind(&self) -> <Self::Layout as OptionLayout>::KindLenField

Returns the wire value for this option kind.

Source

fn serialize_into(&self, data: &mut [u8])

Serializes self into data.

data will be exactly self.serialized_len() bytes long. Implementers must write the data portion of self into data (not the kind or length fields).

§Panics

May panic if data is not exactly self.serialized_len() bytes long.

Implementors§