pub struct Records<B, R: RecordsImplLayout> { /* private fields */ }
Expand description
A parsed set of arbitrary sequential records.
Records
represents a pre-parsed set of records whose structure is enforced
by the impl in O
.
Implementations§
Source§impl<B, R> Records<B, R>where
B: SplitByteSlice,
R: for<'a> RecordsImpl<'a>,
impl<B, R> Records<B, R>where
B: SplitByteSlice,
R: for<'a> RecordsImpl<'a>,
Sourcepub fn parse_with_context(
bytes: B,
context: R::Context,
) -> Result<Records<B, R>, R::Error>
pub fn parse_with_context( bytes: B, context: R::Context, ) -> Result<Records<B, R>, R::Error>
Parse a set 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 owned).
Sourcepub fn parse_with_mut_context(
bytes: B,
context: &mut R::Context,
) -> Result<Records<B, R>, R::Error>
pub fn parse_with_mut_context( bytes: B, context: &mut R::Context, ) -> Result<Records<B, R>, R::Error>
Parse a set of records with a mutable context.
parse_with_mut_context
parses bytes
as a sequence of records. context
may be used by implementers to maintain state and do checks.
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.
Sourcepub fn parse_bv_with_context<BV: BufferView<B>>(
bytes: &mut BV,
context: R::Context,
) -> Result<Records<B, R>, R::Error>
pub fn parse_bv_with_context<BV: BufferView<B>>( bytes: &mut BV, context: R::Context, ) -> Result<Records<B, R>, R::Error>
Parse a set of records with a context, using a BufferView
.
See parse_bv_with_mut_context
for details on bytes
, context
, and
return value. parse_bv_with_context
just calls parse_bv_with_mut_context
with a mutable reference to the context
(which is owned).
Sourcepub fn parse_bv_with_mut_context<BV: BufferView<B>>(
bytes: &mut BV,
context: &mut R::Context,
) -> Result<Records<B, R>, R::Error>
pub fn parse_bv_with_mut_context<BV: BufferView<B>>( bytes: &mut BV, context: &mut R::Context, ) -> Result<Records<B, R>, R::Error>
Parse a set of records with a mutable context, using a BufferView
.
This function is exactly the same as parse_with_mut_context
except instead
of operating on a ByteSlice
, we operate on a BufferView<B>
where B
is a ByteSlice
. parse_bv_with_mut_context
enables parsing records without
knowing the size of all records beforehand (unlike parse_with_mut_context
where callers need to pass in a ByteSlice
of some predetermined sized).
Since callers will provide a mutable reference to a BufferView
,
parse_bv_with_mut_context
will take only the amount of bytes it needs to
parse records, leaving the rest in the BufferView
object. That is, when
parse_bv_with_mut_context
returns, the BufferView
object provided will be
x bytes smaller, where x is the number of bytes required to parse the records.
Source§impl<B, R> Records<B, R>where
B: SplitByteSlice,
R: for<'a> RecordsImpl<'a, Context = ()>,
impl<B, R> Records<B, R>where
B: SplitByteSlice,
R: for<'a> RecordsImpl<'a, Context = ()>,
Source§impl<'a, B, R> Records<B, R>where
B: 'a + SplitByteSlice,
R: RecordsImpl<'a>,
impl<'a, B, R> Records<B, R>where
B: 'a + SplitByteSlice,
R: RecordsImpl<'a>,
Sourcepub fn iter(&'a self) -> RecordsIter<'a, R> ⓘ
pub fn iter(&'a self) -> RecordsIter<'a, R> ⓘ
Create an iterator over options.
iter
constructs an iterator over the records. Since the records were
validated in parse
, then so long as from_kind
and from_data
are
deterministic, the iterator is infallible.