ppp_packet::records

Struct 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: SplitByteSlice, 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: SplitByteSlice, 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 + SplitByteSlice, 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>,

Source§

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

Source§

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