Skip to main content

DatagramObject

Struct DatagramObject 

Source
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: DatagramType

Datagram type byte.

§track_alias: VarInt

Track alias.

§group_id: VarInt

Group ID.

§object_id: VarInt

Object ID. Defaults to 0 when DatagramType::object_id_present is false.

§publisher_priority: u8

Publisher 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

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> DatagramObject

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 DatagramObject

Source§

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

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

impl Eq for DatagramObject

Source§

impl PartialEq for DatagramObject

Source§

fn eq(&self, other: &DatagramObject) -> 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 DatagramObject

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.