Skip to main content

AnyDatagramHeader

Enum AnyDatagramHeader 

Source
pub enum AnyDatagramHeader {
Show 13 variants Draft07(Datagram), Draft08(Datagram), Draft09(Datagram), Draft10(Datagram), Draft11(Datagram), Draft12(Datagram), Draft13(Datagram), Draft14(DatagramObject), Draft15(DatagramHeader), Draft16(DatagramHeader), Draft17(DatagramHeader), Draft18(DatagramHeader), Draft19(DatagramHeader),
}
Expand description

A datagram header from any enabled draft.

encode is fallible on every draft. It dispatches to each draft’s DatagramHeader::encode_checked (draft-14’s DatagramObject::encode_checked), which refuses a header whose Object Status the framing it names cannot carry rather than writing the bytes and dropping the status. Every draft 07-18 says “Any object with a status code other than zero MUST have an empty payload”; draft-19 replaces that blanket rule with a per-status Payload column in the Object Status registry of its Section 15.9. Either way there is no datagram that states End of Group and carries a payload, so a value asking for one is answered with CodecError::InvalidField and nothing is written.

The per-draft encode methods are unchanged and still infallible; they take the framing the value names as the authority and silently discard whatever does not fit it. Reach for one of those only when that is what you want.

Variants§

§

Draft07(Datagram)

Draft-draft07 variant.

§

Draft08(Datagram)

Draft-draft08 variant.

§

Draft09(Datagram)

Draft-draft09 variant.

§

Draft10(Datagram)

Draft-draft10 variant.

§

Draft11(Datagram)

Draft-draft11 variant.

§

Draft12(Datagram)

Draft-draft12 variant.

§

Draft13(Datagram)

Draft-draft13 variant.

§

Draft14(DatagramObject)

Draft-draft14 variant.

§

Draft15(DatagramHeader)

Draft-draft15 variant.

§

Draft16(DatagramHeader)

Draft-draft16 variant.

§

Draft17(DatagramHeader)

Draft-draft17 variant.

§

Draft18(DatagramHeader)

Draft-draft18 variant.

§

Draft19(DatagramHeader)

Draft-draft19 variant.

Implementations§

Source§

impl AnyDatagramHeader

Source

pub fn decode( version: DraftVersion, buf: &mut impl Buf, ) -> Result<Self, CodecError>

Decode from wire using the specified draft version.

Source

pub fn encode(&self, buf: &mut impl BufMut) -> Result<(), CodecError>

Encode to wire using the appropriate draft’s format.

Source

pub fn draft(&self) -> DraftVersion

Returns the draft version this value belongs to.

Source§

impl AnyDatagramHeader

Source

pub fn meta(&self) -> AnyDatagramMeta

This datagram’s identity, without its payload.

One call in place of thirteen match arms. A caller that wants a track alias, a Location or a priority off a datagram has otherwise to destructure the concrete per-draft variant — and on drafts 07 through 13 to destructure again, because those carry a payload datagram and a status datagram as two different structs behind one enum.

See AnyDatagramMeta::object_id for the one field whose absence from the wire is not an absence of the value.

Source

pub fn permits_payload(&self) -> bool

Whether this datagram may carry a non-empty payload.

Drafts 07 through 18 state one blanket rule — “Any object with a status code other than zero MUST have an empty payload” — and draft-19 replaces it with a Payload column in the Object Status registry of its Section 15.9, which grants a payload to the same one status the blanket rule did. The answer is therefore the same shape on all thirteen, and it is the framing that gives it: every draft either splits payload and status datagrams into separate types (08 through 14, and the type byte on 15 and 16) or hangs the status off a declared length of zero (07), so a datagram that states a status is one that has no payload to carry.

Note this asks what the framing permits, not what the value holds. A datagram permitted a payload may still carry none; a zero-length Normal object is legal everywhere.

Before this, a caller had to match the concrete per-draft variant to ask at all, which is why the client carries thirteen arms to do it.

Source

pub fn extensions_permitted(&self) -> Option<bool>

Whether this datagram’s status is allowed to carry the extension headers it has, or None where the draft states no such rule.

The rule enters the specification twice, in two different widths, and a draft-neutral caller must not apply either one outside its range:

  • Drafts 07 through 10 state nothing. Draft-07’s datagram has no extension block at all, and drafts 08, 09 and 10 have one with no rule attached. These answer None rather than true, because “permitted” would imply a rule was consulted.
  • Drafts 11 through 14 state the narrow form, in the section naming the Object Extension Header: “Any Object may have extension headers except those with Object Status ‘Object Does Not Exist’.” One status, and End of Group and End of Track may carry extensions freely.
  • Drafts 15 through 19 state the general form: “Any Object with status Normal can have extension headers. If an endpoint receives extension headers on Objects with status that is not Normal, it MUST close the session with a PROTOCOL_VIOLATION.” Draft-16 also dropped the Object Does Not Exist status, so the narrow form’s subject no longer exists there.

Drafts 17 and later call the block Properties rather than Extensions; the name here follows AnySubgroupObject::extension_headers, which spans the same rename.

This reports rather than refuses, on all thirteen. A frame carrying extensions beside a status is well formed — every length is honest and every field parses — so a decoder hands it back intact and a tool that reproduces a capture can re-emit it. Refusing on decode would make a captured violation unreadable, which loses the one artifact anybody debugging it needs.

Trait Implementations§

Source§

impl Clone for AnyDatagramHeader

Source§

fn clone(&self) -> AnyDatagramHeader

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 AnyDatagramHeader

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.