Skip to main content

SubgroupObject

Struct SubgroupObject 

Source
pub struct SubgroupObject {
    pub object_id: VarInt,
    pub extension_headers: Vec<u8>,
    pub payload_length: VarInt,
    pub object_status: Option<ObjectStatus>,
    pub payload: Vec<u8>,
}
Expand description

One object within a draft-18 subgroup stream. Object IDs are delta-encoded; whether a per-object “properties” block (the draft-18 equivalent of extension headers) is present depends on the PROPERTIES bit on the enclosing SubgroupHeader. Use SubgroupObjectReader to encode/decode.

Fields§

§object_id: VarInt§extension_headers: Vec<u8>

Raw properties bytes, excluding the byte-length prefix that precedes them on the wire. Empty unless the subgroup header sets the PROPERTIES bit, or when the block is present but zero-length. Opaque: SubgroupObjectReader::write_object re-emits the prefix and these bytes verbatim.

§payload_length: VarInt§object_status: Option<ObjectStatus>

The object’s status, carried on the wire only when payload_length is zero: a zero-length object encodes a status code in place of its payload. None with a zero payload_length is written as ObjectStatus::Normal, the status draft-18 Section 11.2.1.1 gives an empty object.

Typed rather than a raw code. The wire field is a varint with room for any value, and draft-18 assigns three of them; the decoder refuses the rest, and this type is that same refusal on the encode side — 0x1 and 0x2 cannot be named here, so SubgroupObjectReader::write_object cannot emit a status this module’s own decoder would reject.

§payload: Vec<u8>

Implementations§

Source§

impl SubgroupObject

Source

pub fn status(&self) -> ObjectStatus

The object’s status, with the one draft-18’s encoding elides filled in.

A subgroup object states its status only when its Object Payload Length is zero. An object that carries bytes therefore has no status field, and its status is ObjectStatus::Normal — the only status draft-18 Section 11.2.1.1 permits a payload, so the only one such an object could have had.

Source

pub fn properties_permitted(&self) -> bool

Whether this object’s status is allowed to carry the properties it has.

Draft-18 Section 11.2.1.2: “Any Object with status Normal can have properties (Section 2.5). If an endpoint receives properties on an Object with status that is not Normal, it MUST close the session with a PROTOCOL_VIOLATION.”

So this is false for exactly one shape: a non-empty properties block on an object whose status is not ObjectStatus::Normal. An object with no properties is fine at any status, and an object at Normal may carry any properties. A zero-length block is “no properties” here and not a violation — Section 11.4.2 requires it of an object on a PROPERTIES subgroup stream that has none: “Objects with no properties set Properties Length to 0.”

Neither SubgroupObjectReader::read_object nor SubgroupObjectReader::write_object applies this itself, which is a deliberate contrast with the payload rule beside it. A status next to a payload has no encoding — the two share a position on the wire — so the writer refuses it as unrepresentable. Properties next to a status encode fine; the frame is well formed and merely non-conforming, and a codec that could not read or write it could not reproduce a capture containing one. The rule addresses an endpoint receiving such an Object, so the endpoint is where it is enforced, and this is what it asks.

The datagram carrier is the exception, and the draft is what makes it one: Section 11.3.1 states the same rule again as a per-datagram framing rule, so DatagramHeader::decode refuses it outright.

Trait Implementations§

Source§

impl Clone for SubgroupObject

Source§

fn clone(&self) -> SubgroupObject

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 SubgroupObject

Source§

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

Formats the value using the given formatter. Read more

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.