Expand description
HTTP Datagram payload coding (RFC 9297) and QUIC varints (RFC 9000 §16).
An HTTP/3 datagram carried in a QUIC DATAGRAM frame is:
Quarter Stream ID (varint) | Context ID (varint) | payloadThe Quarter Stream ID is the request stream’s id divided by four
(RFC 9297 §2.1) — not the stream id itself. Getting this wrong is the failure
mode that makes every UDP session after the first on a connection misroute,
which is exactly the h3-datagram 0.0.2 bug this crate avoids by encoding
datagrams here instead. The unit tests below pin the relationship.
For CONNECT-UDP the Context ID is 0, meaning “the payload is a raw UDP datagram” (RFC 9298 §4).
Structs§
- Datagram
- A decoded HTTP/3 datagram.
Enums§
- Decode
Error - Why a datagram could not be decoded.
Constants§
- CONTEXT_
ID_ UDP_ PAYLOAD - Context ID for an unmodified UDP payload (RFC 9298 §4).
- MAX_
QUARTER_ STREAM_ ID - Largest legal Quarter Stream ID (RFC 9297 §2.1).
- MAX_
UDP_ PAYLOAD - Largest UDP payload that can be represented (RFC 9298 §5).
- VARINT_
MAX - Largest value a QUIC varint can hold (RFC 9000 §16).
Functions§
- decode
- Decodes an HTTP/3 datagram, sharing the payload buffer rather than copying.
- encode
- Encodes an HTTP/3 datagram.
- encode_
udp_ payload - Encodes a datagram for
quarter_stream_idcarrying a raw UDP payload. - encoded_
len - The number of bytes
encodewill produce. - peek_
varint - Decodes the varint at the start of
buf, returning it and its byte length. - put_
varint - Appends
valueas a QUIC varint. - quarter_
stream_ id - The Quarter Stream ID identifying the session on
stream_id. - take_
varint - Reads a QUIC varint from the front of
buf, consuming it. - varint_
len - Encoded length of
valueas a QUIC varint.