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

codec/cbor

lib/codec/cbor.vk

lib/codec/cbor.vk Pure-Veko RFC 8949 CBOR deterministic encoder and decoder. Supports major types 0..5 and 7 (bool, .null, IEEE-754 f64) with canonically sorted map keys. Zero capabilities required.

signature
encode = fn [v any] bytes

Encodes a Veko value into deterministic RFC 8949 CBOR bytes.

Executable Example
veko
use [cbor = codec/cbor]
raw = cbor/encode { count = -100, ok = true, empty = .null, tag = 'veko' }
dec = cbor/decode raw
if (map/get dec 'count') != -100 or (map/get dec 'empty') != .null or (map/get dec 'tag') != 'veko' [
  err 'cbor roundtrip'
] else [ .ok ]
signature
decode = fn [data bytes] any

Decodes RFC 8949 CBOR bytes into a Veko value (CBOR null maps to .null).