pub enum Datagram {
Payload(DatagramHeader),
}Expand description
One datagram, of whichever shape its type field names.
A MoQT datagram opens with a variable-length integer naming its type, and
that integer is what says which of the layouts above follows it — draft-07 names one datagram type, and this is it.
Neither DatagramHeader nor its type field reads or writes it, so neither can be handed
the first byte of a datagram a peer sent, and neither produces bytes a peer
can read. This is the entry point that does both.
The payload of a payload-bearing datagram runs to the end of the QUIC
datagram, so it is not part of this value: Self::decode stops at the end
of the header and leaves the payload in the buffer, and a caller appends the
payload after Self::encode.
Variants§
Payload(DatagramHeader)
An object carrying a payload.
Implementations§
Source§impl Datagram
impl Datagram
Sourcepub fn is_status(&self) -> bool
pub fn is_status(&self) -> bool
Whether this datagram states an Object Status instead of carrying a payload.
Draft-07 has one datagram layout and hangs the status off a declared payload length of zero, so the answer is in the body rather than in the type field.
Sourcepub fn datagram_type(&self) -> StreamType
pub fn datagram_type(&self) -> StreamType
The type field this value writes.
Sourcepub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
pub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
Decode a datagram from its first byte, type field included.
Errors with CodecError::UnknownStreamType when the leading type is
one Table 5 does not assign, which Section 7 answers with a close, and
with CodecError::InvalidField when it assigns the value but to a
stream rather than a datagram. stream_type_error draws that line, and
names the stream rule for both because draft-07 numbers datagrams in the
stream table.
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, refusing a header the framing it names cannot carry.
The body is built before anything reaches buf, so a refused datagram
leaves buf untouched rather than a type field with no body under it.