packet::records::options

Trait OptionLayout

Source
pub trait OptionLayout {
    type KindLenField: KindLenField;

    const LENGTH_ENCODING: LengthEncoding = _;
}
Expand description

Information about an option’s layout.

It is recommended that this trait be implemented for an uninhabited type since it never needs to be instantiated:

/// A carrier for information about the layout of the IPv4 option
/// format.
///
/// This type exists only at the type level, and does not need to be
/// constructed.
pub enum Ipv4OptionLayout {}

impl OptionLayout for Ipv4OptionLayout {
    type KindLenField = u8;
}

Provided Associated Constants§

Source

const LENGTH_ENCODING: LengthEncoding = _

The encoding of the length byte.

Some formats (such as IPv4) use the length field to encode the length of the entire option, including the kind and length bytes. Other formats (such as IPv6) use the length field to encode the length of only the value. This constant specifies which encoding is used.

Additionally, some formats (such as NDP) do not directly encode the length in bytes of each option, but instead encode a number which must be multiplied by a constant in order to get the length in bytes. This is set using the TypeLengthValue variant’s option_len_multiplier field, and it defaults to 1.

Required Associated Types§

Source

type KindLenField: KindLenField

The type of the “kind” and “length” fields in an option.

For most protocols, this is simply u8, as the “kind” and “length” fields are each a single byte. For protocols which use two bytes for these fields, this is [zerocopy::U16].

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§