pub struct SubgroupObjectReader { /* private fields */ }Implementations§
Source§impl SubgroupObjectReader
impl SubgroupObjectReader
pub fn new(header: &SubgroupHeader) -> Self
pub fn read_object( &mut self, buf: &mut impl Buf, ) -> Result<SubgroupObject, CodecError>
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.
A zero payload_length writes the object’s status, with
SubgroupObject::status filling in ObjectStatus::Normal when the
object_status field is None. The status is typed, so every value
that can reach this method is one draft-19 assigns and one
Self::read_object accepts; no unassigned code can be written.
Errors with CodecError::InvalidField when the Object Status registry
(draft-19 Section 15.9) does not permit the object’s status to carry a
payload and a payload was handed over anyway. Draft-19 Section 11.2.1.1
makes that object malformed, and the encoding has no way to state it:
the status field appears only where the payload does not. Writing it
would mean silently discarding one of the two — emitting the bytes as a
Normal object and losing an End of Group marker, say — so it is refused
instead. A status the registry does permit a payload is written as an
ordinary payload object, its status implicit, since that is how the
encoding spells it.
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.
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.
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