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
impl AnyDatagramHeader
Sourcepub fn decode(
version: DraftVersion,
buf: &mut impl Buf,
) -> Result<Self, CodecError>
pub fn decode( version: DraftVersion, buf: &mut impl Buf, ) -> Result<Self, CodecError>
Decode from wire using the specified draft version.
Sourcepub fn encode(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
pub fn encode(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
Encode to wire using the appropriate draft’s format.
Sourcepub fn draft(&self) -> DraftVersion
pub fn draft(&self) -> DraftVersion
Returns the draft version this value belongs to.
Source§impl AnyDatagramHeader
impl AnyDatagramHeader
Sourcepub fn meta(&self) -> AnyDatagramMeta
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.
Sourcepub fn permits_payload(&self) -> bool
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.
Sourcepub fn extensions_permitted(&self) -> Option<bool>
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
Nonerather thantrue, 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
impl Clone for AnyDatagramHeader
Source§fn clone(&self) -> AnyDatagramHeader
fn clone(&self) -> AnyDatagramHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more