Skip to main content

AnySubgroupObjectReader

Struct AnySubgroupObjectReader 

Source
pub struct AnySubgroupObjectReader { /* private fields */ }
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-19 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.

Implementations§

Source§

impl AnySubgroupObjectReader

Source

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.

Source

pub fn draft(&self) -> DraftVersion

The draft this reader decodes.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for AnySubgroupObjectReader

Source§

fn clone(&self) -> AnySubgroupObjectReader

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 AnySubgroupObjectReader

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.