Declaraciones públicas de zig/zstd.zig (conduit-zig (SDK consumido)).
apps/docs/generated/zig/conduit.jsonPágina generada desde
conduit@conduit-0.1.0-f7J_7zg5DwCsHBHItwdOz9ZVq8cvH7ceFsk7-m3-T61t (zig/root.zig). No se edita a mano:bun run docs:genla regenera ybun run docs:checkfalla si difiere.
Content-Encoding: zstd for wire v2 (spec/wire-v2.md §7), without C and
without dependencies, so the same code runs in the CLI, the C-ABI library
and WASM:
Compressor: an LZ77 encoder (greedy, one hash probe) that writes
standard zstd frames (RFC 8878): raw literals, sequences with the
predefined FSE tables, RLE and raw blocks. It trades ratio for
simplicity and speed; any zstd decoder reads its frames (checked
against std.compress.zstd, the zstd CLI and Bun in the tests).decodeFrame: the server's bounded decoder. It checks the frame
header against the wire rules before allocating anything (one
frame, no skippable frame, no dictionary, window ≤ 8 MiB, content
size equal to the range when present), then decodes with
std.compress.zstd.Decompress into a buffer of exactly
window + 128 KiB and hands the bytes to a sink, which bounds the
output. The encoded input is bounded too (max_input, the range
length), whether or not the body had a Content-Length. Trailing
bytes after the frame are refused.Policy: the client rule (§7): never encode video, audio or data that
is already compressed (sniffed from the first bytes), and only encode
when a 64 KiB sample shrinks to ≤ 90 %.zstd.max_windowconst · línea 30
pub const max_window: u64 = 8 << 20Largest window the wire accepts (Window_Size ≤ 8 MiB).
zstd.block_maxconst · línea 31
pub const block_max: usize = zstd.block_size_maxSin ///.
zstd.magicconst · línea 32
pub const magic: u32 = 0xFD2FB528Sin ///.
zstd.max_header_lenconst · línea 35
pub const max_header_len = 18Longest frame header: magic, descriptor, window, 4-byte dictionary id, 8-byte content size.
zstd.min_input_bufferconst · línea 38
pub const min_input_buffer = 2048The decoder peeks up to 2048 bytes for an FSE table description, so the
reader it reads from (decodeFrame's own, over the body) holds at least this.
zstd.Headertype · línea 42
pub const Header = structSin ///.
zstd.HeaderErrorconst · línea 48
pub const HeaderError = error{ /// Not a zstd frame, or one the wire forbids (skippable, dictionary, /// window over 8 MiB, reserved bit). BadFrame, /// The header says the frame holds more bytes than …Sin ///.
zstd.parseHeaderfn · línea 60
pub fn parseHeader(bytes: []const u8, expected: u64) HeaderError!HeaderCheck a frame header against spec/wire-v2.md §7. expected is the
decoded length the request must produce (the range length).
zstd.DecodeErrorconst · línea 113
pub const DecodeError = error{ BadFrame, /// More decoded bytes than `expected` (or the header said so). TooLarge, /// More encoded bytes than `max_input`: whatever the transport framing /// (a `Trans …Sin ///.
zstd.Sinktype · línea 129
pub const Sink = structWhere decoded bytes go. writeFn may refuse (it bounds the output).
zstd.decoderMemoryfn · línea 136
pub fn decoderMemory(w: u64) u64Bytes a decoder holds for a frame with window w.
zstd.decodeFramefn · línea 145
pub fn decodeFrame(gpa: Allocator, in: *Reader, sink: *Sink, expected: u64, max_input: u64) DecodeError!u64Decode exactly one zstd frame from in into sink. in must hold the
encoded body and nothing else (it ends where the body ends); its buffer
may be any size. At most max_input encoded bytes are read: one more is
InputTooLarge, never decoded past. Returns the decoded length; anything
after the frame is BadFrame.
zstd.Compressortype · línea 409
pub const Compressor = structReusable encoder state (~800 KiB): one per worker.
zstd.Compressor.initfn · línea 419
pub fn init(gpa: Allocator) Allocator.Error!CompressorSin ///.
zstd.Compressor.deinitfn · línea 432
pub fn deinit(c: *Compressor) voidSin ///.
zstd.Compressor.compressfn · línea 445
pub fn compress(c: *Compressor, src: []const u8, dst: []u8) ?usizeCompress src into one zstd frame in dst. Null when the frame
does not fit dst (pass dst.len < src.len to get "only if it
shrinks"). The frame carries the content size and a window of at
most 8 MiB, the limits decodeFrame enforces.
zstd.sample_lenconst · línea 652
pub const sample_len = 64 * 1024Sin ///.
zstd.Snifftype · línea 655
pub const Sniff = enumWhat the first bytes of a file say about its payload.
zstd.snifffn · línea 658
pub fn sniff(head: []const u8) SniffVideo, audio and already-compressed containers by their magic bytes.
zstd.worthEncodingfn · línea 679
pub fn worthEncoding(c: *Compressor, head: []const u8) boolSpec §7 client policy on the file's first bytes: encode only payload
that is neither media nor compressed and whose first 64 KiB shrink to
≤ 90 %. c is any compressor (it is reset by compress).