Skip to content

API Reference Overview ​

The lz4.zig public interface provides both top-level one-shot functions and specialized struct types for fine-grained control.

Top-Level One-Shot Functions ​

FunctionSignatureDescription
lz4.compress(arg1, arg2) !OutputPolymorphic one-shot compression: allocates []u8 if arg1 is Allocator, or writes into caller slice arg2.
lz4.compressWithOptions(allocator, src, opts) ![]u8Compresses src with custom CompressionOptions, allocating a new slice for the frame.
lz4.compressInto(src, dst) !usizeCompresses src into caller-allocated dst slice (standard frame format).
lz4.decompress(arg1, arg2) !OutputPolymorphic one-shot decompression: auto-detects frame or block format.
lz4.decompressWithOptions(allocator, src, opts) ![]u8Decompresses src with custom DecompressionOptions (e.g. maxOutputSize).
lz4.decompressInto(src, dst) !usizeDecompresses src directly into caller-allocated dst slice.

Streaming & I/O Functions ​

FunctionSignatureDescription
lz4.compressStream(allocator, reader, writer, opts) !usizeCompresses stream from std.Io.Reader to std.Io.Writer.
lz4.decompressStream(allocator, reader, writer, opts) !usizeDecompresses stream from std.Io.Reader to std.Io.Writer.
lz4.compressFile(allocator, in_path, out_path, opts) !voidCompresses a file on disk into an LZ4 frame file.
lz4.decompressFile(allocator, in_path, out_path) !voidDecompresses an on-disk LZ4 file back to its original format.

Raw Block Low-Level Functions ​

FunctionSignatureDescription
lz4.compressBlock(src, dst) !usizeCompresses a raw block into dst.
lz4.compressFast(src, dst, acceleration) !usizeFast block compression with explicit acceleration factor.
lz4.compressHC(src, dst, level) !usizeHigh-Compression block compression (level 2..12).
lz4.compressUsingDict(src, dst, dict) !usizeCompresses a block using a prefix/external dictionary.
lz4.decompressBlock(src, dst) !usizeDecompresses a raw LZ4 block into caller-allocated dst.
lz4.decompressBlockPartial(src, dst, target_size) !usizeDecompresses up to target_size uncompressed bytes.
lz4.decompressBlockWithDict(src, dst, dict) !usizeDecompresses a raw block using a reference dictionary.

Bounds & Metadata Functions ​

FunctionDescription
lz4.compressBound(size)Calculates worst-case compressed buffer capacity.
lz4.compressFrameBound(size, opts)Calculates worst-case LZ4 frame size including headers and checksums.
lz4.compressBlockBound(size)Calculates worst-case raw block size.
lz4.getFrameInfo(src)Inspects and parses FrameHeader from a compressed slice.
lz4.xxHash32(data, seed)Computes pure Zig xxHash-32 checksum with seed.
lz4.versionString()Returns library version string (0.0.1).

Released under the MIT License.