compress.gzip #
Description:
compress.gzip
is a module that assists in the compression and
decompression of binary data using gzip
compression
Examples:
import compress.gzip
fn main() {
uncompressed := 'Hello world!'
compressed := gzip.compress(uncompressed.bytes())!
decompressed := gzip.decompress(compressed)!
assert decompressed == uncompressed.bytes()
}
Constants #
const (
reserved_bits = 00b11100000
ftext = 00b00000001
fextra = 00b00000100
fname = 00b00001000
fcomment = 00b00010000
fhcrc = 00b00000010
)
fn compress #
fn compress(data []u8) ![]u8
compresses an array of bytes using gzip and returns the compressed bytes in a new array
Example
compressed := gzip.compress(b)!
fn decompress #
fn decompress(data []u8, params DecompressParams) ![]u8
decompresses an array of bytes using zlib and returns the decompressed bytes in a new array
Example
decompressed := gzip.decompress(b)!
fn validate #
fn validate(data []u8, params DecompressParams) !GzipHeader
validate validates the header and returns its details if valid
struct DecompressParams #
struct DecompressParams {
verify_header_checksum bool = true
verify_length bool = true
verify_checksum bool = true
}
struct GzipHeader #
struct GzipHeader {
pub mut:
length int = 10
extra []u8
filename []u8
comment []u8
modification_time u32
operating_system u8
}