nquic_frame (nquic v1.0.0)

View Source

QUIC frame encoding and decoding per RFC 9000 Section 12.4.

Handles all 20+ frame types defined by the QUIC protocol. Encoding produces iodata for zero-copy sending. Decoding uses inline varint macros (?DECODE_VARINT) that preserve the binary match context for performance.

Summary

Functions

Decode a single QUIC frame from binary. Returns {ok, Frame, Rest} or {error, Reason}.

Encode a QUIC frame record to iodata.

Types

t()

-type t() ::
          #padding{} |
          #ping{} |
          #ack{largest_acknowledged :: nquic_packet_number:t(),
               delay :: non_neg_integer(),
               first_ack_range :: non_neg_integer(),
               ack_ranges :: [#ack_range{gap :: non_neg_integer(), length :: non_neg_integer()}],
               ecn_counts :: term() | undefined} |
          #reset_stream{stream_id :: nquic:stream_id(),
                        app_error_code :: nquic:error_code(),
                        final_size :: non_neg_integer()} |
          #stop_sending{stream_id :: nquic:stream_id(), app_error_code :: nquic:error_code()} |
          #crypto{offset :: non_neg_integer(), data :: binary()} |
          #new_token{token :: binary()} |
          #stream{stream_id :: nquic:stream_id(),
                  offset :: non_neg_integer(),
                  length :: non_neg_integer(),
                  fin :: boolean(),
                  data :: iodata()} |
          #max_data{max_data :: non_neg_integer()} |
          #max_stream_data{stream_id :: nquic:stream_id(), max_stream_data :: non_neg_integer()} |
          #max_streams{max_streams :: non_neg_integer(), is_uni :: boolean()} |
          #data_blocked{limit :: non_neg_integer()} |
          #stream_data_blocked{stream_id :: nquic:stream_id(), limit :: non_neg_integer()} |
          #streams_blocked{limit :: non_neg_integer(), is_uni :: boolean()} |
          #new_connection_id{seq_num :: non_neg_integer(),
                             retire_prior_to :: non_neg_integer(),
                             cid :: nquic:connection_id(),
                             stateless_reset_token :: binary()} |
          #retire_connection_id{seq_num :: non_neg_integer()} |
          #path_challenge{data :: binary()} |
          #path_response{data :: binary()} |
          #connection_close{error_code :: non_neg_integer(),
                            frame_type :: non_neg_integer(),
                            reason_phrase :: binary(),
                            is_application :: boolean()} |
          #handshake_done{} |
          #datagram{data :: binary()}.

Functions

decode/1

-spec decode(binary()) -> {ok, t(), binary()} | {error, nquic_error:any_reason()}.

Decode a single QUIC frame from binary. Returns {ok, Frame, Rest} or {error, Reason}.

encode/1

-spec encode(t()) -> iodata().

Encode a QUIC frame record to iodata.