ppp_packet::records::options

Trait OptionsImpl

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

    // Required method
    fn parse(
        kind: u8,
        data: &'a [u8],
    ) -> Result<Option<Self::Option>, Self::Error>;
}
Expand description

An implementation of an options parser.

OptionsImpl provides functions to parse fixed- and variable-length options. It is required in order to construct an Options.

Required Associated Types§

Source

type Option

The type of an option; the output from the parse function.

For long or variable-length data, the user is advised to make Option a reference into the bytes passed to parse. This is achievable because of the lifetime parameter to this trait.

Required Methods§

Source

fn parse(kind: u8, data: &'a [u8]) -> Result<Option<Self::Option>, Self::Error>

Parse an option.

parse takes a kind byte and variable-length data associated and returns Ok(Some(o)) if the option successfully parsed as o, Ok(None) if the kind byte was unrecognized, and Err(err) if the kind byte was recognized but data was malformed for that option kind. parse is allowed to not recognize certain option kinds, as the length field can still be used to safely skip over them.

parse must be deterministic, or else Options::parse cannot guarantee that future iterations will not produce errors (and panic).

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§

Source§

impl<'a> OptionsImpl<'a> for ppp_packet::ipv4::ControlOptionsImpl

Source§

impl<'a> OptionsImpl<'a> for ppp_packet::ipv6::ControlOptionsImpl

Source§

impl<'a> OptionsImpl<'a> for ppp_packet::link::ControlOptionsImpl