Struct ppp_packet::records::Records

source ·
pub struct Records<B, R: RecordsImplLayout> { /* private fields */ }
Expand description

A parsed set of arbitrary sequential records.

Records represents a pre-parsed set of records whose structure is enforced by the impl in O.

Implementations§

source§

impl<B, R> Records<B, R>
where B: ByteSlice, R: for<'a> RecordsImpl<'a>,

source

pub fn parse_with_context( bytes: B, context: R::Context ) -> Result<Records<B, R>, R::Error>

Parse a set 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 owned).

source

pub fn parse_with_mut_context( bytes: B, context: &mut R::Context ) -> Result<Records<B, R>, R::Error>

Parse a set of records with a mutable context.

parse_with_mut_context parses bytes as a sequence of records. context may be used by implementers to maintain state and do checks.

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

pub fn parse_bv_with_context<BV: BufferView<B>>( bytes: &mut BV, context: R::Context ) -> Result<Records<B, R>, R::Error>

Parse a set of records with a context, using a BufferView.

See parse_bv_with_mut_context for details on bytes, context, and return value. parse_bv_with_context just calls parse_bv_with_mut_context with a mutable reference to the context (which is owned).

source

pub fn parse_bv_with_mut_context<BV: BufferView<B>>( bytes: &mut BV, context: &mut R::Context ) -> Result<Records<B, R>, R::Error>

Parse a set of records with a mutable context, using a BufferView.

This function is exactly the same as parse_with_mut_context except instead of operating on a ByteSlice, we operate on a BufferView<B> where B is a ByteSlice. parse_bv_with_mut_context enables parsing records without knowing the size of all records beforehand (unlike parse_with_mut_context where callers need to pass in a ByteSlice of some predetermined sized). Since callers will provide a mutable reference to a BufferView, parse_bv_with_mut_context will take only the amount of bytes it needs to parse records, leaving the rest in the BufferView object. That is, when parse_bv_with_mut_context returns, the BufferView object provided will be x bytes smaller, where x is the number of bytes required to parse the records.

source§

impl<B, R> Records<B, R>
where B: ByteSlice, R: for<'a> RecordsImpl<'a, Context = ()>,

source

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

Parses a set of records.

Equivalent to calling parse_with_context with context = ().

source§

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

source

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

Get the underlying bytes.

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

source§

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

source

pub fn iter(&'a self) -> RecordsIter<'a, R>

Create an iterator over options.

iter constructs an iterator over the records. Since the records were validated in parse, then so long as from_kind and from_data are 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

Auto Trait Implementations§

§

impl<B, R> Freeze for Records<B, R>

§

impl<B, R> RefUnwindSafe for Records<B, R>

§

impl<B, R> Send for Records<B, R>
where B: Send, <R as RecordsImplLayout>::Context: Send,

§

impl<B, R> Sync for Records<B, R>
where B: Sync, <R as RecordsImplLayout>::Context: Sync,

§

impl<B, R> Unpin for Records<B, R>
where B: Unpin, <R as RecordsImplLayout>::Context: Unpin,

§

impl<B, R> UnwindSafe for Records<B, R>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more