compress #
Description
compress
is a namespace for (multiple) compression algorithms supported by V.
At the moment, the following compression algorithms are implemented:
compress.deflate
compress.gzip
compress.zlib
compress.zstd
Constants #
const max_size = u64(1 << 31)
fn compress #
fn compress(data []u8, flags int) ![]u8
compresses an array of bytes based on providing flags and returns the compressed bytes in a new array NB: this is a low level api, a high level implementation like zlib/gzip should be preferred
fn decompress #
fn decompress(data []u8, flags int) ![]u8
decompresses an array of bytes based on providing flags and returns the decompressed bytes in a new array NB: this is a low level api, a high level implementation like zlib/gzip should be preferred
fn decompress_with_callback #
fn decompress_with_callback(data []u8, cb ChunkCallback, userdata voidptr, flags int) !u64
decompress_with_callback decompresses an array of bytes, based on the provided flags, and a V fn callback to receive decompressed chunks, of at most 32 kilobytes each. It returns the total decompressed length, or a decompression error. NB: this is a low level api, a high level implementation like zlib/gzip should be preferred.
type ChunkCallback #
type ChunkCallback = fn (chunk []u8, userdata voidptr) int
ChunkCallback is used to receive decompressed chunks of maximum 32768 bytes. After processing the chunk this function should return the chunk's length to indicate the decompressor to send more chunks, otherwise the decompression stops. The userdata parameter comes from the call to decompress_with_callback/4, and can be used to pass arbitrary data, without having to create a closure.