veko doc
Self-Contained API Reference • Gradual Types • Capabilities • Wasm Sandbox

codec/vbin

lib/codec/vbin.vk

lib/codec/vbin.vk Pure-Veko canonical deterministic self-describing binary codec (VBIN). Encodes booleans, i64, f64, str, bytes, blocks, canonically key-sorted maps, and .null/.enum values. Zero capabilities required.

signature
encode = fn [v any] bytes

Encodes any supported Veko value into canonical deterministic VBIN bytes.

Executable Example
veko
use [vbin = codec/vbin]
orig = { a = 1, b = -42, c = [true .null 'ok'], d = (bytes/from-str 'xy') }
enc = vbin/encode orig
dec = vbin/decode enc
if (map/get dec 'b') != -42 or (map/get dec 'c')[1] != .null [ err 'vbin roundtrip' ] else [ .ok ]
signature
decode = fn [data bytes] any

Decodes VBIN bytes back into a Veko value (wire null maps to .null).