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§
Sourcetype Counter: RecordsCounter
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§
Sourcefn counter_mut(&mut self) -> &mut Self::Counter
fn counter_mut(&mut self) -> &mut Self::Counter
Gets the counter mutably.
Provided Methods§
Sourcefn clone_for_iter(&self) -> Self
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.