pub struct AnySubgroupObjectReader { /* private fields */ }Expand description
Stateful reader for the objects on a subgroup data stream, for any enabled draft.
Drafts 07-13 encode absolute object IDs and need no state, drafts 14-19
delta-encode them against the previous object. This reader presents both
as the same API: construct it from the stream’s header, then call
read_object once per object.
The reader is Clone specifically so callers can probe a partial buffer
against a copy and commit only on success; see the module docs.
Implementations§
Source§impl AnySubgroupObjectReader
impl AnySubgroupObjectReader
Sourcepub fn new(header: &AnySubgroupHeader) -> Result<Self, CodecError>
pub fn new(header: &AnySubgroupHeader) -> Result<Self, CodecError>
Create a reader seeded from the stream’s subgroup header.
Returns CodecError::UnsupportedDraft when the header’s draft is
not compiled in, and CodecError::InvalidField when the header’s
stream type is not a subgroup type.
Sourcepub fn draft(&self) -> DraftVersion
pub fn draft(&self) -> DraftVersion
The draft this reader decodes.
Sourcepub fn read_object(
&mut self,
buf: &mut impl Buf,
) -> Result<AnySubgroupObject, CodecError>
pub fn read_object( &mut self, buf: &mut impl Buf, ) -> Result<AnySubgroupObject, CodecError>
Decode the next object, including its payload.
Returns CodecError::UnexpectedEnd when buf holds only part of an
object; the reader’s state is unspecified after such an error, so
callers that may be fed partial buffers must probe against a clone.
Sourcepub fn read_object_meta(
&mut self,
buf: &mut impl Buf,
) -> Result<AnySubgroupObjectMeta, CodecError>
pub fn read_object_meta( &mut self, buf: &mut impl Buf, ) -> Result<AnySubgroupObjectMeta, CodecError>
Decode the next object’s framing without copying its payload.
Advances buf past the whole object exactly as
read_object does, but returns only scalars.
This is the path a relay uses when it forwards the object’s bytes
verbatim and never inspects the payload.
Trait Implementations§
Source§impl Clone for AnySubgroupObjectReader
impl Clone for AnySubgroupObjectReader
Source§fn clone(&self) -> AnySubgroupObjectReader
fn clone(&self) -> AnySubgroupObjectReader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more