Skip to main content

FetchObjectHeader

Struct FetchObjectHeader 

Source
pub struct FetchObjectHeader {
    pub serialization_flags: u64,
    pub group_id_delta: Option<VarInt>,
    pub subgroup_id: Option<VarInt>,
    pub object_id_delta: Option<VarInt>,
    pub publisher_priority: Option<u8>,
    pub properties: Vec<u8>,
    pub payload_length: VarInt,
}
Expand description

One frame on a draft-18 FETCH stream, exactly as it sits on the wire.

Draft-18 Section 11.4.4 gives the layout as

{
  Serialization Flags (vi64),
  [Group ID Delta (vi64),]
  [Subgroup ID (vi64),]
  [Object ID Delta (vi64),]
  [Publisher Priority (8),]
  [Properties (..),]
  Object Payload Length (vi64),
  [Object Payload (..),]
}

Every optional field is present exactly when the Serialization Flags say so, which is why they are Option here rather than resolved values: this type holds what was written, not what it means. The Object’s actual Group ID, Subgroup ID, Object ID and Priority come from resolving these against the frame before them, which is FetchObjectReader’s job — a header on its own cannot say, because most of its fields are differences from an Object it does not have.

Unlike a subgroup object, a fetch object carries no Object Status: Section 11.2.1.1 says the field “is only present in objects that are delivered via a SUBSCRIPTION, and is absent in Objects delivered via a FETCH”. A zero Object Payload Length here is an empty payload and nothing more.

Fields§

§serialization_flags: u64

The Serialization Flags varint, verbatim. Below 128 it is a set of flags; 0x8C and 0x10C are the two End of Range markers; the decoder refuses everything else.

§group_id_delta: Option<VarInt>

The Group ID Delta field, or — on an End of Range marker — the absolute Group ID that marker names.

§subgroup_id: Option<VarInt>

The explicit Subgroup ID field, present only in subgroup mode 0b11 with the Datagram bit clear.

§object_id_delta: Option<VarInt>

The Object ID Delta field, or — on an End of Range marker — the absolute Object ID that marker names.

§publisher_priority: Option<u8>

The Publisher Priority octet, present only when bit 0x10 is set.

§properties: Vec<u8>

Raw properties bytes, excluding the byte-length prefix that precedes them on the wire. Empty when bit 0x20 is clear, and re-emitted verbatim by Self::encode.

§payload_length: VarInt

Object Payload Length. The payload itself follows the header and is not held here, so that a caller forwarding bytes never has to copy them.

Implementations§

Source§

impl FetchObjectHeader

Source

pub fn end_of_range(&self) -> Option<EndOfRange>

Which End of Range this frame marks, or None when it is an Object.

Draft-18 Section 11.4.4, Table 7 assigns 0x8C and 0x10C, both above the 128 below which the field is a set of flags, so no flag combination can be mistaken for a marker.

Source

pub fn is_datagram(&self) -> bool

true when bit 0x40 marks this Object’s forwarding preference as Datagram, so it has no Subgroup ID.

Draft-18 Section 11.4.4.1: “When encoding an Object with a Forwarding Preference of ‘Datagram’ … the object has no Subgroup ID. The publisher MUST SET bit 0x40 to ‘1’. When 0x40 is set, it SHOULD set the two least significant bits to zero and the subscriber MUST ignore the bits.” Ignoring them is what this predicate is for: with the bit set, the two-bit mode field says nothing, not even when it reads 0b11, so no Subgroup ID is on the wire to read.

Source

pub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>

Decode one frame, without its payload.

Errors with CodecError::InvalidField on a Serialization Flags value that is neither a set of flags nor one of the two End of Range markers. Draft-18 Section 11.4.4 lists the two additional values and then says of the field: “Any other value is a PROTOCOL_VIOLATION.” Nothing after the flags can be read without them, since they are what says which fields are there.

Source

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

Serialize the frame, refusing one that does not describe itself.

The Serialization Flags are the authority on which fields are on the wire, so a field the flags announce and the struct does not hold has no bytes to write, and a field the struct holds and the flags do not announce has nowhere to go. Either way the frame Self::decode would read back is not the one that was handed over, and no caller could repair it by appending bytes — the flags are already written.

Errors with CodecError::InvalidField in those cases and on a flags value the draft does not define, before any byte is written, so a refused frame leaves buf untouched rather than half a frame the next read would run into. This is the fetch counterpart of the rule SubgroupObjectReader::write_object applies to a declared payload length.

Trait Implementations§

Source§

impl Clone for FetchObjectHeader

Source§

fn clone(&self) -> FetchObjectHeader

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 FetchObjectHeader

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for FetchObjectHeader

Source§

impl PartialEq for FetchObjectHeader

Source§

fn eq(&self, other: &FetchObjectHeader) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FetchObjectHeader

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.