pub struct AnySubgroupObjectReader {
state: SubgroupReaderState,
}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-23
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.
Fields§
§state: SubgroupReaderStateImplementations§
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.
Refuses a property block that does not parse, as
crate::object_properties::parse_object_properties does, and, as
CodecError::MalformedTrack, the Prior Group ID Gap conditions one
stream shows on drafts 11-23 and the Prior Object ID Gap ones on drafts
14-23, as each draft’s subgroup reader does;
read_object_meta does not read inside it.
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.