Module compress.gzip stdlib

compress.gzip
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
2
Imported by:
0
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imports

Imported by

This section is empty.

Overview

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()
}

Aliases

This section is empty.

Constants

#constant reserved_bits

reserved_bits = 0b1110_0000

#constant ftext

ftext         = 0b0000_0001

#constant fextra

fextra        = 0b0000_0100

#constant fname

fname         = 0b0000_1000

#constant fcomment

fcomment      = 0b0001_0000

#constant fhcrc

fhcrc         = 0b0000_0010

Sum types

This section is empty.

Functions

#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

Structs

#struct DecompressParams

params
pub struct DecompressParams {
	verify_header_checksum bool = true
	verify_length          bool = true
	verify_checksum        bool = true
}

#struct GzipHeader

noinit
pub struct GzipHeader {
pub mut:
	length            int = 10
	extra             []u8
	filename          []u8
	comment           []u8
	modification_time u32
	operating_system  u8
}

Interfaces

This section is empty.

Enums

This section is empty.