zig/lib/std / compress/gzip.zig

Decompress compressed data from reader and write plain data to the writer.

const deflate = @import("flate/deflate.zig");
const inflate = @import("flate/inflate.zig");

decompress()

Decompressor type


/// Decompress compressed data from reader and write plain data to the writer.
pub fn decompress(reader: anytype, writer: anytype) !void {
    try inflate.decompress(.gzip, reader, writer);
}

Decompressor()

Create Decompressor which will read compressed data from reader.


/// Decompressor type
pub fn Decompressor(comptime ReaderType: type) type {
    return inflate.Decompressor(.gzip, ReaderType);
}

decompressor()

Compression level, trades between speed and compression size.


/// Create Decompressor which will read compressed data from reader.
pub fn decompressor(reader: anytype) Decompressor(@TypeOf(reader)) {
    return inflate.decompressor(.gzip, reader);
}

Options

Compress plain data from reader and write compressed data to the writer.


/// Compression level, trades between speed and compression size.
pub const Options = deflate.Options;

compress()

Compressor type


/// Compress plain data from reader and write compressed data to the writer.
pub fn compress(reader: anytype, writer: anytype, options: Options) !void {
    try deflate.compress(.gzip, reader, writer, options);
}

Compressor()

Create Compressor which outputs compressed data to the writer.


/// Compressor type

Compressor()

Huffman only compression. Without Lempel-Ziv match searching. Faster compression, less memory requirements but bigger compressed sizes.

pub fn Compressor(comptime WriterType: type) type {
    return deflate.Compressor(.gzip, WriterType);
}

huffman


/// Create Compressor which outputs compressed data to the writer.
pub fn compressor(writer: anytype, options: Options) !Compressor(@TypeOf(writer)) {
    return try deflate.compressor(.gzip, writer, options);
}

compress()


/// Huffman only compression. Without Lempel-Ziv match searching. Faster
/// compression, less memory requirements but bigger compressed sizes.
pub const huffman = struct {

compress()

    pub fn compress(reader: anytype, writer: anytype) !void {
        try deflate.huffman.compress(.gzip, reader, writer);
    }

compressor()


Compressor()

    pub fn Compressor(comptime WriterType: type) type {
        return deflate.huffman.Compressor(.gzip, WriterType);
    }

compress()


    pub fn compressor(writer: anytype) !huffman.Compressor(@TypeOf(writer)) {
        return deflate.huffman.compressor(.gzip, writer);
    }
};

Compressor()


// No compression store only. Compressed size is slightly bigger than plain.
pub const store = struct {
    pub fn compress(reader: anytype, writer: anytype) !void {
        try deflate.store.compress(.gzip, reader, writer);
    }

compressor()


    pub fn Compressor(comptime WriterType: type) type {
        return deflate.store.Compressor(.gzip, WriterType);
    }

    pub fn compressor(writer: anytype) !store.Compressor(@TypeOf(writer)) {
        return deflate.store.compressor(.gzip, writer);
    }
};