Type Alias Options

Source
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,

Source

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.

Source

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 = ()>,

Source

pub fn parse(bytes: B) -> Result<Records<B, R>, R::Error>

Parses a sequence of records.

Equivalent to calling parse_with_context with context = ().

Source§

impl<B: Deref<Target = [u8]>, R> Records<B, R>
where R: RecordsImpl,

Source

pub fn bytes(&self) -> &[u8]

Gets the underlying bytes.

bytes returns a reference to the byte slice backing this Records.

Source§

impl<B, R> Records<B, R>
where B: ByteSlice, R: RecordsImpl,

Source

pub fn as_ref(&self) -> Records<&[u8], R>

Returns the same records but coerces the backing B type to &[u8].

Source§

impl<'a, B, R> Records<B, R>
where B: 'a + SplitByteSlice, R: RecordsImpl,

Source

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.

Source

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,

Source

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: Debug, R: Debug + RecordsImplLayout> Debug for Records<B, R>
where R::Context: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B, R> FromRaw<RecordsRaw<B, R>, ()> for Records<B, R>
where R: RecordsImpl, B: SplitByteSlice,

Source§

type Error = <R as RecordsImplLayout>::Error

The type of error that may happen during validation.
Source§

fn try_from_raw_with(raw: RecordsRaw<B, R>, _args: ()) -> Result<Self, R::Error>

Attempts to create Self from the raw form in raw with args.
Source§

fn try_from_raw(raw: R) -> Result<Self, <Self as FromRaw<R, A>>::Error>
where Self: FromRaw<R, (), Error = <Self as FromRaw<R, A>>::Error>,

Attempts to create Self from the raw form in raw.
Source§

impl<B: PartialEq, R: PartialEq + RecordsImplLayout> PartialEq for Records<B, R>
where R::Context: PartialEq,

Source§

fn eq(&self, other: &Records<B, R>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<B, R: RecordsImplLayout> StructuralPartialEq for Records<B, R>