NURLNURL registrynurl-lang.org →

← zst

zst 0.2.0 API

inspect.nu

packages/zst/src/inspect.nu — what is actually inside a .zst file.

A Zstandard frame is a header, a run of blocks, and an optional checksum; each compressed block is a literals section and a sequences section, and each of those chose an encoding the encoder thought cheapest. All of that is recoverable WITHOUT entropy-decoding anything — the choices are announced in bytes and bitfields at the front of each section — which is what this file reads out.

It is the view you want when a file compresses worse than you expected and you need to know why: whether the literals went Huffman or raw, whether the tree was sent or repeated, whether the sequence tables were the predefined ones, how many sequences each block carries. The reference CLI's --list stops at the frame.

API

: i ZI_MAGIC 0xFD2FB528

: i ZI_SKIP_LO 0x184D2A50

: i ZI_SKIP_HI 0x184D2A5F

@ zst_inspect ( Vec u ) src s name → i

Print the anatomy of every frame in src. Returns 0, or 1 when the file stops making sense partway through.


main.nu

zst — Zstandard on the command line, with no Zstandard underneath.

zst c FILE compress → FILE.zst zst d FILE.zst decompress → FILE zst t FILE.zst… verify: checksum, structure, exact sizes zst i FILE.zst inspect: every frame and block, and why zst b FILE bench: compression and decompression here

With no FILE (or -) it is a filter: stdin to stdout, bytes in, bytes out. Frames it writes are ordinary Zstandard frames — unzstd reads them — and frames the zstd CLI writes are read here, both directions checked against that CLI by tools/zstd_gate.sh in the compiler repo.

zst never deletes an input file. The reference CLI removes the source on success unless you pass -k; here the safe thing is the only thing, and rm is right there.

API

@ main → i