code wiki / _hdl_build / nx_canon_bin.nx

nx_canon_bin.nx

buildroot/runtime/_hdl_build/nx_canon_bin.nx

5108 B108 linesdepth 6pulls 6 transitivereach 10 importersview sourcekind librarytopic canon
docsdependenciesstructsconstsfunctions

about

nx_canon_bin.nx -- BINARY-SAFE canonical records, built ON TOP of nx_canon_cid (the substrate pattern: do NOT touch the foundation -- Rule 19 additive, Rule 3 no patch cascade; sibling of nx_uxf_cid). The shipped canon_encode derives value length from strlen => STRING-ONLY (a value with a 0x00 byte truncates), so it cannot carry image/audio/compressed-text payloads. This adds the SAME NXR1 canonical form (magic "NXR1" | u32be nfields | per field KEY-SORTED: u32be klen | key | u32be vlen | value) with EXPLICIT value lengths => binary-safe. Re-encoding the same fields reproduces identical bytes => identical cid_of() CID (audit 2026-06-22: this is the primitive .nmz / the media container needs; candidate for the substrate ws to adopt as canon_encode_bin proper). license_tier: ORIGINAL

dependencies 2 imports · 10 importers

nx_syscalls.nx nx_canon_cid.nx nx_canon_bin.nx nx_audio_gate.nx nx_canon_bin_gate.nx nx_fb2_book_gate.nx nx_m4b_gate.nx nx_nmz_author.nx nx_nmz_comic_gate.nx nx_nmz_gate.nx nx_nmz_index.nx nx_nmz_native_gate.nx nx_nmz_pack.nx

imports: nx_syscalls.nxnx_canon_cid.nx

imported by: nx_audio_gate.nxnx_canon_bin_gate.nxnx_fb2_book_gate.nxnx_m4b_gate.nxnx_nmz_author.nxnx_nmz_comic_gate.nxnx_nmz_gate.nxnx_nmz_index.nxnx_nmz_native_gate.nxnx_nmz_pack.nx

structs

none

consts

none

functions

12func cb_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
13func cb_w32(p: *u8, o: i64, v: i64) -> i64 { p[o]=((v>>24)&0xff) as u8; p[o+1]=((v>>16)&0xff) as u8; p[o+2]=((v>>8)&0xff) as u8; p[o+3]=(v&0xff) as u8; return o+4 }
called by 1: canon_encode_bin
14func cb_be32(b: *u8, o: i64) -> i64 { return ((b[o] as i64)<<24)|((b[o+1] as i64)<<16)|((b[o+2] as i64)<<8)|(b[o+3] as i64) }
16func cb_cmp(a: *u8, b: *u8) -> i64 { var i: i64=0; while 1==1 { let ca: i64=a[i] as i64; let cb: i64=b[i] as i64; if ca!=cb { return ca-cb } if ca==0 { return 0 } i=i+1 } return 0 }
called by 1: canon_encode_bin
20func canon_encode_bin(keys: *i64, vals: *i64, vlens: *i64, n: i64, out: *u8) -> i64
54func canon_get_bin(m: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64
82func canon_decode_bin(m: *u8, n: i64, out_keys: *i64, out_voff: *i64, out_vlens: *i64, maxf: i64) -> i64
called by 1: main calls 2: cb_be32sys_mmap