pub struct DatagramObject {
pub datagram_type: DatagramType,
pub track_alias: VarInt,
pub group_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
Datagram carrying a single object.
Fields§
§datagram_type: DatagramTypeDatagram type byte.
track_alias: VarIntTrack alias.
group_id: VarIntGroup ID.
object_id: VarIntObject ID. Defaults to 0 when
DatagramType::object_id_present is false.
publisher_priority: u8Publisher priority.
extension_headers: Vec<u8>Raw extension-header bytes (empty unless
DatagramType::extensions_present is true).
status: Option<ObjectStatus>Object status (only present for status-type datagrams).
payload: Vec<u8>Object payload (empty for status-type datagrams).
Implementations§
Source§impl DatagramObject
impl DatagramObject
Sourcepub fn encode_checked(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
pub fn encode_checked(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
Encode the datagram in full, refusing a field the type byte cannot carry.
Draft-14 Section 10.3.1 states the framing rule outright: “The Object
Status field and Object Payload are mutually exclusive.” Types 0x00
through 0x07 carry a payload and omit the status field; types 0x20 and
0x21 carry a status field and have no payload. This value can hold both
at once, and Self::encode resolves the disagreement by writing
whichever one the type byte announces and discarding the other without a
word. An End of Group marker written under a payload type does not
arrive late or malformed — it does not arrive at all, and the receiver
sees an ordinary object in its place; a payload written under a status
type vanishes the same way.
ObjectStatus::Normal under a payload type is not that case and is
accepted. Section 10.2.1.1 says “Any object with a status code other
than zero MUST have an empty payload”, so Normal is the status a
payload-bearing object already has, and stating it asks for exactly the
bytes leaving it out asks for.
Errors with CodecError::InvalidField on either lossy combination,
before any byte is written, so a refused datagram leaves buf
untouched.
Sourcepub fn encode(&self, buf: &mut impl BufMut)
pub fn encode(&self, buf: &mut impl BufMut)
Encode the datagram in full.
The type byte is taken as the authority on framing, which is what makes
this infallible — and what makes it lossy when the value disagrees with
itself. A status set under a payload type, or a payload set under a
status type, is discarded here without a word. Prefer
Self::encode_checked, which refuses those combinations instead of
resolving them.
Sourcepub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
pub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
Decode a datagram. The buffer must contain the full datagram — payload-bearing types extend to the end of the QUIC datagram, which the caller is responsible for delimiting.
Trait Implementations§
Source§impl Clone for DatagramObject
impl Clone for DatagramObject
Source§fn clone(&self) -> DatagramObject
fn clone(&self) -> DatagramObject
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more