packet::records

Trait RecordsContext

Source
pub trait RecordsContext: Sized + Clone {
    type Counter: RecordsCounter;

    // Required method
    fn counter_mut(&mut self) -> &mut Self::Counter;

    // Provided method
    fn clone_for_iter(&self) -> Self { ... }
}
Expand description

The context kept while performing records parsing.

Types which implement RecordsContext can be used as the long-lived context which is kept during records parsing. This context allows parsers to keep running computations over the span of multiple records.

Required Associated Types§

Source

type Counter: RecordsCounter

A counter used to keep track of how many records are left to parse.

See the documentation on RecordsCounter for more details.

Required Methods§

Source

fn counter_mut(&mut self) -> &mut Self::Counter

Gets the counter mutably.

Provided Methods§

Source

fn clone_for_iter(&self) -> Self

Clones a context for iterator purposes.

clone_for_iter is useful for cloning a context to be used by RecordsIter. Since Records::parse_with_context will do a full pass over all the records to check for errors, a RecordsIter should never error. Therefore, instead of doing checks when iterating (if a context was used for checks), a clone of a context can be made specifically for iterator purposes that does not do checks (which may be expensive).

The default implementation of this method is equivalent to Clone::clone.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl RecordsContext for u8

Source§

type Counter = u8

Source§

fn counter_mut(&mut self) -> &mut u8

Source§

impl RecordsContext for u16

Source§

type Counter = u16

Source§

fn counter_mut(&mut self) -> &mut u16

Source§

impl RecordsContext for u32

Source§

type Counter = u32

Source§

fn counter_mut(&mut self) -> &mut u32

Source§

impl RecordsContext for u64

Source§

type Counter = u64

Source§

fn counter_mut(&mut self) -> &mut u64

Source§

impl RecordsContext for u128

Source§

type Counter = u128

Source§

fn counter_mut(&mut self) -> &mut u128

Source§

impl RecordsContext for ()

Source§

type Counter = ()

Source§

fn counter_mut(&mut self) -> &mut ()

Source§

impl RecordsContext for usize

Source§

type Counter = usize

Source§

fn counter_mut(&mut self) -> &mut usize

Implementors§