nx_cbor.nx
buildroot/runtime/nx_cbor.nx
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
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
| 40 | const NX_CBOR_MAJ_UINT: nx_int = 0 // 0x00 | length |
| 41 | const NX_CBOR_MAJ_NINT: nx_int = 1 // 0x20 | length |
| 42 | const NX_CBOR_MAJ_ARRAY: nx_int = 4 // 0x80 | length |
| 43 | const NX_CBOR_MAJ_MAP: nx_int = 5 // 0xA0 | length |
| 47 | const NX_CBOR_LEN_INLINE_MAX: nx_int = 24 |
| 48 | const NX_CBOR_LEN_BYTE_1: nx_int = 24 |
| 49 | const NX_CBOR_LEN_BYTE_2: nx_int = 25 |
| 50 | const NX_CBOR_LEN_BYTE_4: nx_int = 26 |
| 51 | const NX_CBOR_LEN_BYTE_8: nx_int = 27 |
| 53 | const NX_CBOR_U8_MAX: nx_int = 256 |
| 54 | const NX_CBOR_U16_MAX: nx_int = 65536 |
| 55 | const NX_CBOR_U32_MAX: nx_int = 4294967296 |
| 172 | const NX_CBOR_SPAN_KEY_TRACE: nx_int = 0 |
| 173 | const NX_CBOR_SPAN_KEY_SPAN: nx_int = 1 |
| 174 | const NX_CBOR_SPAN_KEY_PARENT: nx_int = 2 |
| 175 | const NX_CBOR_SPAN_KEY_KIND: nx_int = 3 |
| 176 | const NX_CBOR_SPAN_KEY_START: nx_int = 4 |
| 177 | const NX_CBOR_SPAN_KEY_END: nx_int = 5 |
| 178 | const NX_CBOR_SPAN_KEY_ATTRS: nx_int = 6 |
| 179 | const NX_CBOR_SPAN_N_PAIRS: nx_int = 7 |
functions
| 59 | func _nx_cbor_pow2(n: nx_int) -> nx_int |
| 74 | func nx_cbor_put_byte(buf: *u8, pos: nx_int, b: nx_int) -> nx_int called by 1: nx_cbor_put_length |
| 84 | func nx_cbor_put_length(buf: *u8, pos: nx_int, major: nx_int, value: nx_int) -> nx_int |
| 127 | func nx_cbor_emit_u64(buf: *u8, pos: nx_int, value: nx_int) -> nx_int |
| 137 | func nx_cbor_emit_i64(buf: *u8, pos: nx_int, value: nx_int) -> nx_int |
| 147 | func nx_cbor_emit_array_header(buf: *u8, pos: nx_int, n_elements: nx_int) -> nx_int |
| 153 | func nx_cbor_emit_map_header(buf: *u8, pos: nx_int, n_pairs: nx_int) -> nx_int |
| 181 | func nx_cbor_emit_span(buf: *u8, pos: nx_int, |
| 224 | func nx_cbor_flush_fd(fd: nx_int, buf: *u8, n: nx_int) -> nx_int calls 1: sys_write |