packet::records

Struct 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: 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<'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§

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>

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.

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.