Deflate module

inflate

procedureextensionsince 0.28.0Source

Decompresses data into a new buffer. max_output bounds the result (a compressed bomb fails instead of exhausting memory). A GZIP stream is a single member; bytes after the stream are ignored. On failure the output is empty and error says why.

Example↗
#import "Extensions/Deflate";

packed := deflate(cast([] u8) "abcabcabc", .ZLIB);
output, ok, error := inflate(packed, .ZLIB);
assert(ok);
assert(cast(string) output == "abcabcabc");

_, ok = inflate(cast([] u8) "not deflate data", .ZLIB);
assert(!ok);
inflate :: (
    data: [] u8,
    container := Deflate_Container.ZLIB,
    max_output: s64 = DEFAULT_MAX_OUTPUT
) -> (output: [] u8, ok: bool, error: string)

Parameters

data: [] u8
container := Deflate_Container.ZLIB
max_output: s64 = DEFAULT_MAX_OUTPUT

Returns

output: [] u8
ok: bool
error: string

See also