pub struct SubgroupObjectReader { /* private fields */ }Expand description
Stateful reader/writer for draft-15 subgroup objects.
Carries the running delta state for object IDs and remembers whether extension headers are present on this stream.
Implementations§
Source§impl SubgroupObjectReader
impl SubgroupObjectReader
Sourcepub fn new(header: &SubgroupHeader) -> Self
pub fn new(header: &SubgroupHeader) -> Self
Build a reader seeded from the enclosing subgroup header.
Sourcepub fn read_object(
&mut self,
buf: &mut impl Buf,
) -> Result<SubgroupObject, CodecError>
pub fn read_object( &mut self, buf: &mut impl Buf, ) -> Result<SubgroupObject, CodecError>
Decode the next object from buf.
Sourcepub fn read_object_meta(
&mut self,
buf: &mut impl Buf,
) -> Result<SubgroupObjectMeta, CodecError>
pub fn read_object_meta( &mut self, buf: &mut impl Buf, ) -> Result<SubgroupObjectMeta, CodecError>
Decode the next object’s framing without copying its payload.
Consumes exactly the bytes Self::read_object consumes and leaves
the same delta state behind, so the two are interchangeable on a
given stream.
Sourcepub fn write_object(
&mut self,
object: &SubgroupObject,
buf: &mut impl BufMut,
) -> Result<(), CodecError>
pub fn write_object( &mut self, object: &SubgroupObject, buf: &mut impl BufMut, ) -> Result<(), CodecError>
Serialize an object, producing the correct delta encoding.
Errors with CodecError::InvalidField when object.object_id is
not strictly greater than the previously written object’s ID, since
no valid delta exists for that case.
A zero payload_length makes this a status object, and the status
field is then mandatory on the wire: an absent
SubgroupObject::object_status is written as
ObjectStatus::Normal. The code written is always one draft-15
assigns, because the field cannot hold any other, so the bytes this
produces are always bytes SubgroupObjectReader::read_object accepts.
Errors with CodecError::InvalidField when payload_length is not
exactly payload.len(). The declared length is written ahead of the
payload, so a mismatch is a frame Self::read_object cannot parse
and one no caller could fix by appending bytes.
Does NOT refuse extension headers beside a status other than Normal,
though draft-15 Section 10.2.1.2 forbids them. Such a frame is well
formed and merely non-conforming, this is the only writer a subgroup
object has, and the corpus ships one — so refusing here would leave a
captured violation impossible to reproduce.
SubgroupObject::extensions_permitted reports it instead.
Trait Implementations§
Source§impl Clone for SubgroupObjectReader
impl Clone for SubgroupObjectReader
Source§fn clone(&self) -> SubgroupObjectReader
fn clone(&self) -> SubgroupObjectReader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more