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
const ftext = 00b00000001
const fextra = 00b00000100
const fname = 00b00001000
const fcomment = 00b00010000
const 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 #
@[params]
struct DecompressParams {
pub:
verify_header_checksum bool = true
verify_length bool = true
verify_checksum bool = true
}
struct GzipHeader #
@[noinit]
struct GzipHeader {
pub mut:
length int = 10
extra []u8
filename []u8
comment []u8
modification_time u32
operating_system u8
}