pub struct FetchObject {
pub group_id: VarInt,
pub subgroup_id: VarInt,
pub object_id: VarInt,
pub publisher_priority: u8,
pub extension_headers: Vec<u8>,
pub status: Option<ObjectStatus>,
pub payload: Vec<u8>,
}Expand description
One object carried on a fetch stream.
Every object on a fetch stream is self-describing — unlike subgroup streams, there is no delta encoding and extension headers are always length-prefixed (the length is zero when absent).
Fields§
§group_id: VarIntGroup ID.
subgroup_id: VarIntSubgroup ID. For objects whose Forwarding Preference is Datagram, this is set to the Object ID.
object_id: VarIntObject ID.
publisher_priority: u8Publisher priority.
extension_headers: Vec<u8>Raw extension-header bytes (opaque sequence of Key-Value-Pairs).
status: Option<ObjectStatus>Object status when payload.is_empty(), otherwise None.
payload: Vec<u8>Object payload.
Implementations§
Source§impl FetchObject
impl FetchObject
Sourcepub fn status(&self) -> ObjectStatus
pub fn status(&self) -> ObjectStatus
The status this object resolves to.
The wire carries a status field only on an empty object, so an object
holding bytes is ObjectStatus::Normal whatever status says.
Sourcepub fn permits_payload(&self) -> bool
pub fn permits_payload(&self) -> bool
Whether this object’s status permits it a non-empty payload.
Answered from the status alone, for the reason
SubgroupObject::permits_payload gives. Note that
Self::encode_checked refuses the pairing this reports on, so a
false here is a value that will not be written rather than one
already on the wire.
Sourcepub fn encode_checked(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
pub fn encode_checked(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
Encode one fetch object, refusing a value the wire shape cannot carry.
A fetch object holds a status and a payload in the same value, and the
wire form has room for only one: the Object Status field is written only
when Object Payload Length is zero. Self::encode settles that by
following the status and dropping the payload, which loses the payload
without saying so. This refuses instead, before any byte is written, so
a rejected object leaves buf untouched.
Section 10.2.1.1: “Any object with a status code other than zero MUST have an empty payload.” Normal beside a payload is therefore not a disagreement — it is the status a payload-bearing object already has — and it is written as an ordinary payload-bearing object.
Extension headers on an Object Does Not Exist status are refused for the separate reason given in Section 10.2.1.2.
Unlike a subgroup stream, a fetch object always carries its Extension Headers Length field, so a length of zero is an ordinary object with no extensions and is written as such.
Sourcepub fn encode(&self, buf: &mut impl BufMut)
pub fn encode(&self, buf: &mut impl BufMut)
Encode one fetch object.
Infallible because the status is taken as the authority on framing, and
lossy for the same reason: a payload set beside a status is discarded
here without a word. Prefer Self::encode_checked, which refuses that
combination rather than resolving it.
Sourcepub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
pub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
Decode one fetch object.
Sourcepub fn decode_meta(buf: &mut impl Buf) -> Result<FetchObjectMeta, CodecError>
pub fn decode_meta(buf: &mut impl Buf) -> Result<FetchObjectMeta, CodecError>
Decode one fetch object’s framing without copying its payload.
Consumes exactly the bytes Self::decode consumes.
Trait Implementations§
Source§impl Clone for FetchObject
impl Clone for FetchObject
Source§fn clone(&self) -> FetchObject
fn clone(&self) -> FetchObject
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more