Skip to content

API Reference Overview ​

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

Top-Level One-Shot Functions ​

FunctionSignatureDescription
snappy.compress(allocator, src) ![]u8Compresses src into a standard Snappy framed stream (.sz).
snappy.compressWithOptions(allocator, src, opts) ![]u8Compresses src with custom CompressionOptions.
snappy.compressInto(src, dst) !usizeCompresses src into caller-allocated dst slice (zero heap allocation).
snappy.decompress(allocator, src) ![]u8Decompresses src, auto-detecting framed streams and raw blocks.
snappy.decompressWithOptions(allocator, src, opts) ![]u8Decompresses src with custom DecompressionOptions (e.g. maxOutputSize).
snappy.decompressInto(src, dst) !usizeDecompresses src directly into caller-allocated dst slice.
snappy.compressFramed(allocator, src) ![]u8Explicit framed stream compression.
snappy.decompressFramed(allocator, src) ![]u8Explicit framed stream decompression.
snappy.compressBlock(allocator, src) ![]u8Compresses raw Snappy block with varint length prefix.
snappy.decompressBlock(allocator, src) ![]u8Decompresses raw Snappy block with varint length prefix.

Streaming & I/O Functions ​

FunctionSignatureDescription
snappy.compressStream(allocator, reader, writer, opts) StreamError!voidCompresses stream from std.Io.Reader to std.Io.Writer.
snappy.decompressStream(allocator, reader, writer, opts) StreamError!voidDecompresses stream from std.Io.Reader to std.Io.Writer.
snappy.compressFile(allocator, in_path, out_path, opts) !voidCompresses an on-disk file into a Snappy framed file.
snappy.decompressFile(allocator, in_path, out_path, opts) !voidDecompresses an on-disk Snappy framed file.

Bounds & Metadata Functions ​

FunctionSignatureDescription
snappy.maxCompressedSize(len)(usize) usizeCalculates upper bound for raw block compression (32 + N + N / 6).
snappy.compressBound(len)(usize) usizeAlias for maxCompressedSize.
snappy.maxFramedCompressedSize(len)(usize) usizeCalculates upper bound for framed stream (.sz) compression.
snappy.uncompressedLength(src)([]const u8) !usizeParses expected uncompressed length from a raw block varint prefix.
snappy.isValidCompressedBuffer(src)([]const u8) boolChecks if a buffer begins with a valid varint length header.
snappy.versionString()() []const u8Returns library version string (0.0.1).
snappy.versionNumber()() u32Returns integer version code ((major << 16) | (minor << 8) | patch).

Released under the MIT License.