Skip to main content

Module varint

Module varint 

Source
Expand description

QUIC variable-length integer encoding (RFC 9000 Section 16).

The high 2 bits of the first byte encode the length:

  • 00 = 1 byte (6-bit value, max 63)
  • 01 = 2 bytes (14-bit value, max 16383)
  • 10 = 4 bytes (30-bit value, max 1073741823)
  • 11 = 8 bytes (62-bit value, max 4611686018427387903)

Constants§

VARINT_MAX
Maximum value that fits in a QUIC variable-length integer (62 bits).

Functions§

decode
Decode a QUIC variable-length integer from a buffer.
encode
Encode a QUIC variable-length integer into bytes.
encoded_len
Get the byte length that would be needed to encode value.