4#ifndef PROTOCORE_QUIC_VARINT_H
5#define PROTOCORE_QUIC_VARINT_H
35#define QUIC_VARINT_MAX 0x3FFFFFFFFFFFFFFFull
40 size_t (*
len)(
const uint8_t *, uint64_t);
41 size_t (*
encode)(
const uint8_t *, uint8_t *, size_t, uint64_t);
42 embed_bool (*
decode)(
const uint8_t *,
const uint8_t *, size_t, uint64_t *,
size_t *);
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
embed_bool protocore_quic_varint_decode(const uint8_t *work, const uint8_t *in, size_t len, uint64_t *value, size_t *consumed)
Decode a varint at in. Sets value and consumed (1/2/4/8). false if .
size_t protocore_quic_varint_encode(const uint8_t *work, uint8_t *out, size_t cap, uint64_t value)
Encode value in its shortest form. bytes written, or 0 on overflow .
size_t protocore_quic_varint_len(const uint8_t *work, uint64_t value)
Bytes value encodes to (1 / 2 / 4 / 8), or 0 if it exceeds .
Dispatch table. Addressed by offset, so the layout is asserted below.
embed_bool(* decode)(const uint8_t *, const uint8_t *, size_t, uint64_t *, size_t *)
size_t(* encode)(const uint8_t *, uint8_t *, size_t, uint64_t)
size_t(* len)(const uint8_t *, uint64_t)