nx_bgzf.nx
buildroot/runtime/nx_bgzf.nx
about
nx_bgzf.nx -- BGZF (Blocked GZIP Format) container per SAMv1 §4.1.
BGZF wraps each block in a gzip member with an extra "BC" subfield
carrying BSIZE = total block bytes - 1, allowing random access
(a reader can advance exactly one block without inflating).
G6.0e.1: nx_bgzf_eof_marker -- the canonical 28-byte EOF marker
that every BAM file MUST end with (SAMv1 §4.1.2; htslib uses
the literal byte sequence). This is a well-known fixed
sequence; encoded as a fixed-Huffman empty DEFLATE block.
G6.0e.2: nx_bgzf_write_stored_block -- write a single BGZF block
carrying `data` of length `len` using DEFLATE BTYPE=00
(stored / no compression). Always succeeds for len up to the
stored-block limit (65504 bytes; keeps total ≤ 65535).
Composes nx_crc32 (CRC-32 of the uncompressed payload) and
nx_le_write_u16/u32 (all multi-byte fields little-endian).
Compressed BGZF blocks (BTYPE=01/10) require a DEFLATE ENCODER
which the substrate does not yet ship (nx_deflate is decode-only).
Stored-block BGZF is a fully spec-conformant BAM container and
htslib will read it without warning.
expect_exit: 0
license_tier: ORIGINAL
dependencies 4 imports · 2 importers
imports: nx_syscalls.nxnx_const.nxnx_le.nxnx_crc32.nx
imported by: nx_bam_file_compose_test.nxnx_bgzf_test.nx
structs
| none |
consts
| 37 | const NX_BGZF_STORED_PAYLOAD_MAX: i64 = 65504 |
| 38 | const NX_BGZF_STORED_OVERHEAD: i64 = 31 // bytes added around payload |
| 39 | const NX_BGZF_EOF_MARKER_LEN: i64 = 28 |
functions
| 50 | func nx_bgzf_eof_marker(out_bytes: *u8, max_out: i64) -> i64 |
| 97 | func nx_bgzf_write_stored_block(data: *u8, len: i64, |