Skip to main content

FetchObjectReader

Struct FetchObjectReader 

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

Resolves the delta-encoded fields of the frames on one FETCH stream.

Draft-19 Section 11.4.4.1 defines nearly every field of a fetch frame against “the prior Object”, so no frame after the first can be understood on its own. This holds what the frames so far established, in the two parts the draft keeps separate: Section 11.4.4.2 says that after an End of Range marker the prior Group ID and Object ID are the marker’s, while the prior Subgroup ID and Priority are still “from the last actual Object before the End of Range indicator”.

Every rule the section answers with a PROTOCOL_VIOLATION is refused here with CodecError::InvalidField: a first Object that references fields no prior Object established, a Subgroup ID or Priority inherited when there is none to inherit, and an arithmetic result outside the 64-bit range.

Implementations§

Source§

impl FetchObjectReader

Source

pub fn new(group_order: GroupOrder) -> Self

A reader for a stream whose Groups arrive in group_order.

Source

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

Decode the next frame’s header and resolve its fields.

Consumes the header only. The Object Payload is header.payload_length bytes and stays in buf, so a caller that forwards payloads never copies them and one that ignores them can skip.

Errors with CodecError::InvalidField on every rule Section 11.4.4.1 states:

  • “The first Object MUST include a Group ID Delta and Object ID Delta, and these values are the absolute Group ID and Object ID. If the first Object in the FETCH response uses a flag that references fields in the prior Object, the Subscriber MUST close the session with a PROTOCOL_VIOLATION.” Each such flag is refused where it is read, so the reason survives: a missing delta, an inherited Priority and an inherited Subgroup ID are three different frames, all of them referencing an Object that does not exist.
  • “If the computed Group ID would be less than 0 or greater than 2^64-1, the Subscriber MUST close the Session with error ‘PROTOCOL_VIOLATION’” — the descending and ascending ends of the same rule.
  • “If the computed Object ID would be greater than 2^64-1, the Subscriber MUST close the Session with error ‘PROTOCOL_VIOLATION’.”

Trait Implementations§

Source§

impl Clone for FetchObjectReader

Source§

fn clone(&self) -> FetchObjectReader

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 FetchObjectReader

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.