Struct packet::records::Records

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

A parsed sequence of records.

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

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>

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: ByteSlice, R: for<'a> RecordsImpl<'a, 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: for<'a> RecordsImpl<'a>,

source

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

Gets the underlying bytes.

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

source§

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

source

pub fn iter(&'a self) -> RecordsIter<'a, 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 for<'a> R: RecordsImpl<'a>, B: ByteSlice,

§

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§

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

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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>

Auto Trait Implementations§

§

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.

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.