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§
Required Methods§
Sourcefn parse(kind: u8, data: &'a [u8]) -> Result<Option<Self::Option>, Self::Error>
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.