pub type Options<B, O> = Records<B, O>;
Expand description
A parsed sequence of options.
Options
represents a parsed sequence of options, for example from an
IPv4 or TCP header or an NDP packet. Options
uses Records
under
the hood.
Aliased Type§
struct Options<B, O> { /* private fields */ }
Implementations
Source§impl<B, R> Records<B, R>where
B: SplitByteSlice,
R: RecordsImpl,
impl<B, R> Records<B, R>where
B: SplitByteSlice,
R: RecordsImpl,
Sourcepub fn parse_with_context(
bytes: B,
context: R::Context,
) -> Result<Records<B, R>, R::Error>
pub fn parse_with_context( bytes: B, context: R::Context, ) -> Result<Records<B, R>, R::Error>
Parses a sequence of records with a context.
See parse_with_mut_context
for details on bytes
, context
, and
return value. parse_with_context
just calls parse_with_mut_context
with a mutable reference to the context
which is passed by value to
this function.
Sourcepub fn parse_with_mut_context(
bytes: B,
context: &mut R::Context,
) -> Result<Records<B, R>, R::Error>
pub fn parse_with_mut_context( bytes: B, context: &mut R::Context, ) -> Result<Records<B, R>, R::Error>
Parses a sequence of records with a mutable context.
context
may be used by implementers to maintain state while parsing
multiple records.
parse_with_mut_context
performs a single pass over all of the records
to verify that they are well-formed. Once parse_with_context
returns
successfully, the resulting Records
can be used to construct
infallible iterators.
Source§impl<B, R> Records<B, R>where
B: SplitByteSlice,
R: RecordsImpl<Context = ()>,
impl<B, R> Records<B, R>where
B: SplitByteSlice,
R: RecordsImpl<Context = ()>,
Source§impl<B, R> Records<B, R>where
B: ByteSlice,
R: RecordsImpl,
impl<B, R> Records<B, R>where
B: ByteSlice,
R: RecordsImpl,
Source§impl<'a, B, R> Records<B, R>where
B: 'a + SplitByteSlice,
R: RecordsImpl,
impl<'a, B, R> Records<B, R>where
B: 'a + SplitByteSlice,
R: RecordsImpl,
Sourcepub fn iter(&'a self) -> RecordsIter<'a, &'a [u8], R> ⓘ
pub fn iter(&'a self) -> RecordsIter<'a, &'a [u8], R> ⓘ
Iterates over options.
Since the records were validated in parse
, then so long as
R::parse_with_context
is deterministic, the iterator is infallible.
Sourcepub fn iter_bytes(&'a self) -> RecordsBytesIter<'a, &'a [u8], R> ⓘ
pub fn iter_bytes(&'a self) -> RecordsBytesIter<'a, &'a [u8], R> ⓘ
Iterates over byte slices corresponding to options.
Since the records were validated in parse
, then so long as
R::parse_with_context
is deterministic, the iterator is infallible.
Unrecognized record types will still be included as long as they don’t
fail length validation, even if they would be skipped by the
RecordsIter
returned by Records::iter
.
Source§impl<'a, B, R> Records<B, R>where
B: SplitByteSlice + IntoByteSlice<'a>,
R: RecordsImpl,
impl<'a, B, R> Records<B, R>where
B: SplitByteSlice + IntoByteSlice<'a>,
R: RecordsImpl,
Sourcepub fn into_iter(self) -> RecordsIter<'a, B, R> ⓘ
pub fn into_iter(self) -> RecordsIter<'a, B, R> ⓘ
Iterates over options.
Since the records were validated in parse
, then so long as
R::parse_with_context
is deterministic, the iterator is infallible.
Trait Implementations
Source§impl<B, R> FromRaw<RecordsRaw<B, R>, ()> for Records<B, R>where
R: RecordsImpl,
B: SplitByteSlice,
impl<B, R> FromRaw<RecordsRaw<B, R>, ()> for Records<B, R>where
R: RecordsImpl,
B: SplitByteSlice,
Source§type Error = <R as RecordsImplLayout>::Error
type Error = <R as RecordsImplLayout>::Error
Source§fn try_from_raw_with(raw: RecordsRaw<B, R>, _args: ()) -> Result<Self, R::Error>
fn try_from_raw_with(raw: RecordsRaw<B, R>, _args: ()) -> Result<Self, R::Error>
Self
from the raw form in raw
with args
.