codec/vbin
lib/codec/vbin.vklib/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.
encode = fn [v any] bytes
Encodes any supported Veko value into canonical deterministic VBIN bytes.
Executable Example
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 ]
decode = fn [data bytes] any
Decodes VBIN bytes back into a Veko value (wire null maps to .null).