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: u64The 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: VarIntObject 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
impl FetchObjectHeader
Sourcepub fn end_of_range(&self) -> Option<EndOfRange>
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.
Sourcepub fn is_datagram(&self) -> bool
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.
Sourcepub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
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.
Sourcepub fn encode(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
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
impl Clone for FetchObjectHeader
Source§fn clone(&self) -> FetchObjectHeader
fn clone(&self) -> FetchObjectHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more