code wiki / (root) / nx_cbor.nx

nx_cbor.nx

buildroot/runtime/nx_cbor.nx

7834 B226 linesdepth 2pulls 2 transitivereach 9 importersview sourcekind librarytopic cbor
docsdependenciesstructsconstsfunctions

about

nx_cbor.nx -- RFC 8949 Concise Binary Object Representation, minimal encoder for the substrate's machine-readable wire format. CBOR is the IETF-standard binary JSON-equivalent (RFC 8949). Same information model as JSON, ~30-50% smaller on the wire, deterministic byte-output, zero schema infrastructure. Used by COSE, CoAP, Dapr, and IPLD; chosen here over Parquet/Arrow because: * spans are small + irregularly-shaped (CBOR strength) * we want sovereign-no-deps (one file, pure NishiLang) * the same logical span can ship to JSONL (human) AND CBOR (machine) Spec: RFC 8949 https://www.rfc-editor.org/rfc/rfc8949.html Major types implemented (subset sufficient for spans): 0 unsigned integer 1 negative integer (encoded as -1-value, unsigned) 4 array of N items 5 map of N pairs Major types deferred (queued): 2 byte string 3 text string (UTF-8) 6 tag 7 floats / simple values genealogy_id: bormann_hoffman_2013_cbor + rfc_8949 lineage_id: substrate_native_cbor_v1

dependencies 2 imports · 9 importers

nx_syscalls.nx nx_tier.nx nx_cbor.nx nx_cbor_decode.nx nx_cbor_decode_test.nx nx_cbor_test.nx nx_dashboard.nx nx_dashboard_test.nx nx_log_chunked.nx nx_log_chunked_test.nx nx_trace_query.nx nx_trace_query_test.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_cbor_decode.nxnx_cbor_decode_test.nxnx_cbor_test.nxnx_dashboard.nxnx_dashboard_test.nxnx_log_chunked.nxnx_log_chunked_test.nxnx_trace_query.nxnx_trace_query_test.nx

structs

none

consts

40const NX_CBOR_MAJ_UINT: nx_int = 0 // 0x00 | length
41const NX_CBOR_MAJ_NINT: nx_int = 1 // 0x20 | length
42const NX_CBOR_MAJ_ARRAY: nx_int = 4 // 0x80 | length
43const NX_CBOR_MAJ_MAP: nx_int = 5 // 0xA0 | length
47const NX_CBOR_LEN_INLINE_MAX: nx_int = 24
48const NX_CBOR_LEN_BYTE_1: nx_int = 24
49const NX_CBOR_LEN_BYTE_2: nx_int = 25
50const NX_CBOR_LEN_BYTE_4: nx_int = 26
51const NX_CBOR_LEN_BYTE_8: nx_int = 27
53const NX_CBOR_U8_MAX: nx_int = 256
54const NX_CBOR_U16_MAX: nx_int = 65536
55const NX_CBOR_U32_MAX: nx_int = 4294967296
172const NX_CBOR_SPAN_KEY_TRACE: nx_int = 0
173const NX_CBOR_SPAN_KEY_SPAN: nx_int = 1
174const NX_CBOR_SPAN_KEY_PARENT: nx_int = 2
175const NX_CBOR_SPAN_KEY_KIND: nx_int = 3
176const NX_CBOR_SPAN_KEY_START: nx_int = 4
177const NX_CBOR_SPAN_KEY_END: nx_int = 5
178const NX_CBOR_SPAN_KEY_ATTRS: nx_int = 6
179const NX_CBOR_SPAN_N_PAIRS: nx_int = 7

functions

59func _nx_cbor_pow2(n: nx_int) -> nx_int
74func nx_cbor_put_byte(buf: *u8, pos: nx_int, b: nx_int) -> nx_int
called by 1: nx_cbor_put_length
84func nx_cbor_put_length(buf: *u8, pos: nx_int, major: nx_int, value: nx_int) -> nx_int
127func nx_cbor_emit_u64(buf: *u8, pos: nx_int, value: nx_int) -> nx_int
137func nx_cbor_emit_i64(buf: *u8, pos: nx_int, value: nx_int) -> nx_int
147func nx_cbor_emit_array_header(buf: *u8, pos: nx_int, n_elements: nx_int) -> nx_int
153func nx_cbor_emit_map_header(buf: *u8, pos: nx_int, n_pairs: nx_int) -> nx_int
181func nx_cbor_emit_span(buf: *u8, pos: nx_int,
224func nx_cbor_flush_fd(fd: nx_int, buf: *u8, n: nx_int) -> nx_int
calls 1: sys_write