x.compress.brotli #
Brotli compression and decompression implemented in V.
fn compress #
fn compress(data []u8, params CompressParams) ![]u8
compress encodes data as a Brotli stream using the requested quality and window. Large inputs without metadata, custom dictionaries, or large windows may use the system encoder when available; other inputs use the V encoder.
fn decompress #
fn decompress(data []u8, params DecompressParams) ![]u8
decompress reverses compress() and decodes the RFC 7932 trivial stream layout. Empty input is invalid; an encoded empty stream decodes to an empty array. Malformed headers and non-zero alignment padding are rejected.
struct CompressParams #
@[params]
struct CompressParams {
// quality selects the compression effort from 0 to 11.
pub:
quality int = 5
// window_size selects the RFC 7932 window size from 16 to 24.
window_size int = 16
// large_window selects the incompatible large-window format from 10 to 30.
large_window int
// comment embeds a metadata comment of at most 80 bytes.
comment []u8
// dictionary supplies a custom LZ77 dictionary.
dictionary []u8
}
CompressParams controls Brotli compression.
struct DecompressParams #
@[params]
struct DecompressParams {
pub:
// concatenated accepts multiple Brotli streams in one input buffer.
concatenated bool
// comment requires the stream metadata to match this comment.
comment []u8
// dictionary supplies a custom LZ77 dictionary for distance references.
dictionary []u8
}
DecompressParams controls Brotli decompression.