Expand description
Binary TLV codec (varint + frames) for LogLine Workspace.
Provides:
- Varint (u64): base-128 encoding with MSB as continuation bit
- TLV: Tag (u8) + optional Length (varint) + Value (bytes)
- Frames:
typ (u8) + len (varint) + payload
Fixed-size types (CID32, PUBKEY32, SIG64) don’t carry length (known size).
§Security Limits
MAX_FRAME_LEN: Hard limit on frame payload (~1 MiB) to prevent DoSMAX_VARINT_BYTES: Maximum bytes for varint encoding (10) to prevent overflow
Structs§
Enums§
- Binary
Codec Error - Errors from binary codec operations.
Constants§
- MAX_
BYTES_ LEN - Maximum bytes for variable-length TLV fields (same as frame limit).
- MAX_
FRAME_ LEN - Hard limit for frame payload size (~1 MiB). Prevents memory exhaustion DoS.
- MAX_
VARINT_ BYTES - Maximum bytes for a varint-encoded u64 (ceil(64/7) = 10).
- T_BYTES
- Tag for variable-length bytes.
- T_CID32
- Tag for 32-byte CID (BLAKE3).
- T_
PUBKE Y32 - Tag for 32-byte Ed25519 public key.
- T_SIG64
- Tag for 64-byte Ed25519 signature.
- T_STR
- Tag for UTF-8 string.
- T_U64
- Tag for varint-encoded u64.
Functions§
- decode_
frame - Decodes a frame, returning
(typ, payload). - decode_
varint_ u64 - Decodes a base-128 varint from
inputstarting atpos, advancingpos. - encode_
frame - Encodes a frame:
typ (u8) + len (varint) + payload. - encode_
varint_ u64 - Encodes a
u64as a base-128 varint, appending toout.