These libraries are experimental. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.
GZip
@korulang/gzip@0.0.1Gzip compression for Koru - compile-time or runtime
gzip/index.kz · 7 tors
@korulang/gzip - Gzip compression for Koru · 15 more lines
@korulang/gzip - Gzip compression for Koru
Wraps zlib (the industry standard) for gzip compression/decompression.
Works at both compile-time and runtime.
USAGE:
~import koru/gzip
~koru/gzip:compress(data: my_bytes, allocator: alloc)
| compressed c |> // c.data is gzipped, c.original_size for stats
| error e |> // e is the []const u8 error message directly
~koru/gzip:decompress(data: gzipped, allocator: alloc)
| decompressed d |> // d is the []const u8 original content directly
| error e |> ...
Phantom lifecycles
Derived from the phantom labels in the declarations below — state! issues an
obligation the compiler will chase, !state discharges it, a bare state holds it without moving it. Nothing here is hand-drawn.
Deflater 3 states open!fed!done!compress
index.kz:64// COMPRESS - Main compression event with level control
~pub tor compress { data: string, level: ?Level, allocator: std.mem.Allocator }
| compressed { data: string, original_size: usize }
| error stringcompress-bytes
index.kz:134// COMPRESS_BYTES - Simpler variant for comptime usage
~pub tor compress-bytes { data: string, allocator: std.mem.Allocator }
| ok string
| error stringdecompress
index.kz:187// DECOMPRESS - Decompress gzipped data
~pub tor decompress { data: string, allocator: std.mem.Allocator }
| decompressed string
| error string~pub tor deflate.init { level: ?Level }
| ok *Deflater<open!>
| err string~pub tor deflate.push { d: *Deflater<!open|!fed>, chunk: string }
| ok *Deflater<fed!>
| err string~pub tor deflate.finish { d: *Deflater<!fed> }
| done { d: *Deflater<done!>, data: string }
| err string// Discharge the <done!> obligation: copy the compressed bytes out into
// caller-owned memory, then free the Deflater and its internal buffer.
// After this call `data` (borrowed) is gone but `bytes` (owned) is yours.
~pub tor deflate.release { d: *Deflater<!done>, data: string } -> string