Self-Delimiting Numeric Values (RFC 6256)
OCaml 94.1%
Dune 0.4%
Other 5.5%
25 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-sdnv https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-sdnv
git@git.recoil.org:gazagnaire.org/ocaml-sdnv git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-sdnv

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

SDNV - Self-Delimiting Numeric Values (RFC 6256)#

Variable-length integer encoding used by LTP (CCSDS 734.1-B-1), Bundle Protocol, and other space protocols. Provides efficient encoding of arbitrary-precision integers with self-delimiting properties.

Supports:

  • In-memory encoding/decoding to bytes
  • Streaming I/O with bytesrw

Installation#

opam install sdnv will install this library.

Usage#

open Sdnv

(* Encode a value *)
let encoded = encode 300L

(* Decode from bytes *)
match decode encoded 0 with
| Ok (value, consumed) -> Printf.printf "Value: %Ld (%d bytes)\n" value consumed
| Error Truncated -> print_endline "Truncated input"
| Error Overflow -> print_endline "Value too large"

(* Streaming with bytesrw *)
let value = read_exn reader
write writer 42L

Reference#