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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl RecordsContext for u8

§

type Counter = u8

source§

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

source§

impl RecordsContext for u16

§

type Counter = u16

source§

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

source§

impl RecordsContext for u32

§

type Counter = u32

source§

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

source§

impl RecordsContext for u64

§

type Counter = u64

source§

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

source§

impl RecordsContext for u128

§

type Counter = u128

source§

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

source§

impl RecordsContext for ()

§

type Counter = ()

source§

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

source§

impl RecordsContext for usize

§

type Counter = usize

source§

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

Implementors§