Skip to main content

SubgroupObjectReader

Struct SubgroupObjectReader 

Source
pub struct SubgroupObjectReader { /* private fields */ }
Expand description

Stateful reader for the object fields on a subgroup stream.

Object IDs on a subgroup stream are delta-encoded against the previous Object ID, and whether extension headers are present is fixed by the enclosing SubgroupHeader’s stream type. This reader carries that context across successive read_object calls.

Implementations§

Source§

impl SubgroupObjectReader

Source

pub fn new(header: &SubgroupHeader) -> Self

Create a reader from a parsed subgroup header.

Source

pub fn read_object( &mut self, buf: &mut impl Buf, ) -> Result<SubgroupObject, CodecError>

Decode the next object from buf. Caller is responsible for ensuring the buffer contains a complete object (draft-14 objects are length-delimited by the payload-length field, so the buffer boundary is known once the header portion has been consumed).

Source

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.

Source

pub fn write_object( &mut self, object: &SubgroupObject, buf: &mut impl BufMut, ) -> Result<(), CodecError>

Serialize a subgroup object using the reader’s delta state. Intended for senders that want to build a stream incrementally — tracks prev_object_id so successive calls produce correct deltas.

Returns an error if object.object_id <= prev_object_id, which would produce an invalid delta.

It also refuses the three shapes the stream cannot carry, rather than writing whichever half fits and dropping the rest:

  • A non-empty payload beside a status other than Normal. Section 10.2.1.1: “Any object with a status code other than zero MUST have an empty payload.” A truncated payload is worse than a refusal — the receiver has no way to tell that anything was there.
  • Extension headers on an object whose stream type says the subgroup has none. The type byte is fixed for the whole stream by the header, so this object cannot opt in, and its extensions would simply vanish.
  • Extension headers on an Object Does Not Exist status, per Section 10.2.1.2.

Normal beside a non-empty payload is not one of those and is written as an ordinary payload-bearing object: it is the status such an object already has, so naming it asks for the bytes leaving it out asks for. Normal beside an empty payload keeps the explicit status form, which is the only way to send a zero-length object at all.

Trait Implementations§

Source§

impl Clone for SubgroupObjectReader

Source§

fn clone(&self) -> SubgroupObjectReader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SubgroupObjectReader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.