Expand description
bun_zstd - pure Rust zstd via zstd_pure_rs (replaces vendor/zstd C library). All compress/decompress delegates to zstd_pure_rs::prelude.
Re-exports§
pub use zstd_pure_rs::prelude::ZSTD_EndDirective::ZSTD_e_continue;pub use zstd_pure_rs::prelude::ZSTD_ResetDirective::ZSTD_reset_session_and_parameters;
Modules§
- error_
codes - Error code constants — kept as c_uint values for NativeZstd compatibility.
Structs§
- InBuffer
- Rust-native buffer types replacing the C FFI ZSTD_inBuffer/ZSTD_outBuffer. NativeZstd’s Context uses these instead of raw pointers.
- OutBuffer
- ZSTD_
CCtx - Port of
ZSTD_CCtx. Holds a reusable match state, seqStore, and entropy tables so successiveZSTD_compressCCtxcalls amortize allocation. Also backs the simple streaming API —initCStreamcaptures the level,compressStreambuffers input,endStreamcompresses the buffered input and drains the result. - Zstd
Reader Array List
Enums§
- Result
- State
- ZSTD_
DReset Directive - Port of
ZSTD_ResetDirective(decoder-side alias). - ZSTD_
EndDirective - Port of
ZSTD_EndDirective. TellsZSTD_compressStream2whether the current call should flush / end the frame / just continue buffering. - ZSTD_
Error Code - Sum of all ZSTD error codes. Values are fixed by upstream and must
not drift; they are serialized indirectly through
(size_t)-codereturn values from the C-compatible API. - ZSTD_
Reset Directive - Port of
ZSTD_ResetDirective(zstd.h:589). Upstream fixes the discriminants at 1/2/3 — not the Rust default 0/1/2. FFI callers passing the numeric values directly rely on this. - ZSTD_
cParameter - Port of
ZSTD_cParameter— the parameter id enum for the parametricZSTD_CCtx_setParameter/ZSTD_CCtx_getParameterAPI. Only the subset that our compressor actually honors is exposed; unsupported ids returnParameterUnsupported. - ZSTD_
dParameter - Port of
ZSTD_dParameter— parametric decoder configuration. Only the subset we honor is exposed; callers setting unsupported ids getParameterUnsupported. - Zstd
Error
Constants§
Functions§
- ZSTD_
CCtx_ reset - Port of
ZSTD_CCtx_reset. Matches upstream’s three modes: - ZSTD_
CCtx_ setParameter - Port of
ZSTD_CCtx_setParameter. Stashes the value on the CCtx for subsequent calls. ForcompressionLevel, behavior matchesZSTD_initCStream(level). For the frame flags, the next compression call honors them. - ZSTD_
CCtx_ setPledged SrcSize - Port of
ZSTD_CCtx_setPledgedSrcSize. Declares the exact number of bytes the caller intends to feed throughcompressStreambeforeendStream. When set, the emitted frame header includes the content-size field (enabling some decoder optimizations) andZSTD_getCParamsuses the hint to pick tighter cParams. - ZSTD_
DCtx_ reset - Port of
ZSTD_DCtx_reset. Matches upstream’s three modes: clear per-frame streaming state onsession_only, restore default parameters + drop the configured dict onparameters, do both onsession_and_parameters. - ZSTD_
DCtx_ setParameter - Port of
ZSTD_DCtx_setParameter. ForwindowLogMaxwe record the bound on the DCtx for potential upper-bound checks during frame-header parsing. v0.1 just stashes the value; the enforcement path lands alongside the ZSTD_windowLog_max limit check. - ZSTD_
compress Stream2 - Port of
ZSTD_compressStream2. Unified streaming compression entry point that dispatches based onend_op: - ZSTD_
createC Ctx - Port of
ZSTD_createCCtx. Returns an empty context — all heap allocations happen lazily on the firstZSTD_compressCCtxcall. - ZSTD_
createD Ctx - Port of
ZSTD_createDCtx. Rust port returns an ownedZSTD_DCtxwith default seq-tables pre-built. - ZSTD_
decompress Stream - Port of
ZSTD_decompressStream. Buffersinput[input_pos..]into the DCtx, detects when a complete frame has been received viaZSTD_findFrameCompressedSize, decodes it into an internal output buffer, and drains the result intooutput[output_pos..]. - ZSTD_
defaultC Level - Port of
ZSTD_defaultCLevel. Upstream default is 3. - ZSTD_
freeC Ctx - Port of
ZSTD_freeCCtx. Drop the context; Rust’sBoxhandles deallocation. Returns 0 (upstream returns 0 on success). - ZSTD_
freeD Ctx - Port of
ZSTD_freeDCtx. In the Rust port, dropping the Box frees. - ZSTD_
getError Code - ZSTD_
getError Name - ZSTD_
getError String - ZSTD_
isError - compress
- compress_
bound - decompress
- decompress_
alloc - force_
link - No-op function retained for link-propagation compatibility.
- get_
decompressed_ size
Type Aliases§
- ZSTD_
DStream - Port of
ZSTD_DStream. Upstreamtypedef ZSTD_DCtx ZSTD_DStream— same struct for both APIs.