quic_frame (quic v1.3.0)
View SourceQUIC frame encoding and decoding.
This module handles encoding and decoding of all 21 QUIC frame types as defined in RFC 9000 Section 12.4.
Summary
Functions
Decode a single frame from binary. Returns {Frame, Rest} or {error, Reason}.
Decode all frames from a packet payload. Returns a list of frames.
Encode a frame to binary.
Encode a frame as iodata. For STREAM frames with a binary Data this returns [Header, Data] without copying the payload into the frame binary, avoiding one full copy per chunk on the bulk-send hot path. For all other frame types (and STREAM with iolist Data) this falls back to encode/1 wrapped in a list — iolist_to_binary/1 over the result equals encode/1 for any frame.
Types
-type ecn_counts() :: {ECT0 :: non_neg_integer(), ECT1 :: non_neg_integer(), ECNCE :: non_neg_integer()}.
-type frame() :: padding | ping | {ack, AckRanges :: [{non_neg_integer(), non_neg_integer()}], AckDelay :: non_neg_integer(), ECNCounts :: ecn_counts() | undefined} | {reset_stream, StreamId :: non_neg_integer(), ErrorCode :: non_neg_integer(), FinalSize :: non_neg_integer()} | {reset_stream_at, StreamId :: non_neg_integer(), ErrorCode :: non_neg_integer(), FinalSize :: non_neg_integer(), ReliableSize :: non_neg_integer()} | {stop_sending, StreamId :: non_neg_integer(), ErrorCode :: non_neg_integer()} | {crypto, Offset :: non_neg_integer(), Data :: binary()} | {new_token, Token :: binary()} | {stream, StreamId :: non_neg_integer(), Offset :: non_neg_integer(), Data :: binary(), Fin :: boolean()} | {max_data, MaxData :: non_neg_integer()} | {max_stream_data, StreamId :: non_neg_integer(), MaxData :: non_neg_integer()} | {max_streams, bidi | uni, MaxStreams :: non_neg_integer()} | {data_blocked, Limit :: non_neg_integer()} | {stream_data_blocked, StreamId :: non_neg_integer(), Limit :: non_neg_integer()} | {streams_blocked, bidi | uni, Limit :: non_neg_integer()} | {new_connection_id, SeqNum :: non_neg_integer(), RetirePrior :: non_neg_integer(), CID :: binary(), StatelessResetToken :: binary()} | {retire_connection_id, SeqNum :: non_neg_integer()} | {path_challenge, Data :: binary()} | {path_response, Data :: binary()} | {connection_close, transport | application, ErrorCode :: non_neg_integer(), FrameType :: non_neg_integer() | undefined, Reason :: binary()} | handshake_done | {datagram, Data :: binary()} | {datagram_with_length, Data :: binary()}.
Functions
Decode a single frame from binary. Returns {Frame, Rest} or {error, Reason}.
Decode all frames from a packet payload. Returns a list of frames.
Encode a frame to binary.
Encode a frame as iodata. For STREAM frames with a binary Data this returns [Header, Data] without copying the payload into the frame binary, avoiding one full copy per chunk on the bulk-send hot path. For all other frame types (and STREAM with iolist Data) this falls back to encode/1 wrapped in a list — iolist_to_binary/1 over the result equals encode/1 for any frame.