pub trait RecordsImpl<'a>: RecordsImplLayout {
type Record;
// Required method
fn parse_with_context<BV: BufferView<&'a [u8]>>(
data: &mut BV,
context: &mut Self::Context,
) -> Result<Option<Option<Self::Record>>, Self::Error>;
}
Expand description
An implementation of a records parser.
RecordsImpl
provides functions to parse sequential records. It is required
in order to construct a Records
or RecordsIter
.
Required Associated Types§
Required Methods§
Sourcefn parse_with_context<BV: BufferView<&'a [u8]>>(
data: &mut BV,
context: &mut Self::Context,
) -> Result<Option<Option<Self::Record>>, Self::Error>
fn parse_with_context<BV: BufferView<&'a [u8]>>( data: &mut BV, context: &mut Self::Context, ) -> Result<Option<Option<Self::Record>>, Self::Error>
Parse a record with some context.
parse_with_context
takes a variable-length data
and a context
to
maintain state, and returns Ok(Some(Some(o)))
if the the record is
successfully parsed as o
, Ok(Some(None))
if data is not malformed
but the implementer can’t extract a concrete object (e.g. record is an
unimplemented enumeration, but we can still safely “skip” it), Ok(None)
if parse_with_context
is unable to parse more records, and Err(err)
if the data
was malformed for the attempted record parsing.
data
MAY be empty. It is up to the implementer to handle an exhausted
data
.
When returning Ok(Some(None))
it’s the implementer’s responsibility to
nonetheless skip the record (which may not be possible for some
implementations, in which case it should return an Err
).
parse_with_context
must be deterministic, or else
Records::parse_with_context
cannot guarantee that future iterations
will not produce errors (and panic).
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.