Skip to main content

SubgroupObjectReader

Struct SubgroupObjectReader 

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

Implementations§

Source§

impl SubgroupObjectReader

Source

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

Source

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

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 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

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, <T as TryFrom<U>>::Error>

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.