compression

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Predefined compression levels.
	//
	// Compatible with flate, gzip, zlib.
	NoCompression       int = 0
	BestSpeed           int = 1
	BestCompression     int = 9
	DefaultCompression  int = -1
	ConstantCompression int = -2
	HuffmanOnly         int = -2

	// Source: https://pkg.go.dev/github.com/klauspost/compress/gzip#pkg-constants
	//
	// StatelessCompression will do compression but without maintaining any state
	// between Write calls.
	// There will be no memory kept between Write calls,
	// but compression and speed will be suboptimal.
	// Because of this, the size of actual Write calls will affect output size.
	StatelessCompression int = -3

	// Zstd specific predefined compression levels.
	//
	// Compatible with only zstd.
	ZstdSpeedBestCompression   int = 11
	ZstdSpeedDefault           int = 3
	ZstdSpeedFastest           int = 1
	ZstdSpeedBetterCompression int = 7

	// Brotil specific predefined compression levels.
	//
	// Compatible with only brotli.
	BrotliBestCompression    int = 11
	BrotliDefaultCompression int = 6
	BrotliBestSpeed          int = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Brotli added in v0.0.2

type Brotli struct {
	Level int
	// contains filtered or unexported fields
}

func (*Brotli) Compress added in v0.0.2

func (b *Brotli) Compress(in []byte) ([]byte, error)

func (*Brotli) CompressStream added in v0.0.2

func (b *Brotli) CompressStream(in io.Reader, out io.Writer) error

func (*Brotli) Decompress added in v0.0.2

func (b *Brotli) Decompress(in []byte) ([]byte, error)

func (*Brotli) DecompressStream added in v0.0.2

func (b *Brotli) DecompressStream(in io.Reader, out io.Writer) error

func (*Brotli) GetLevel added in v0.0.2

func (b *Brotli) GetLevel() int

func (*Brotli) GetModes added in v0.1.0

func (b *Brotli) GetModes() []int

func (*Brotli) GetName added in v0.0.2

func (b *Brotli) GetName() string

func (*Brotli) SetLevel added in v0.0.2

func (b *Brotli) SetLevel(level int)

type Compressor

type Compressor interface {
	Compress([]byte) ([]byte, error)
	Decompress([]byte) ([]byte, error)
	CompressStream(io.Reader, io.Writer) error
	DecompressStream(io.Reader, io.Writer) error
	GetLevel() int
	SetLevel(int)
	GetName() string
	GetModes() []int
}

type Flate

type Flate struct {
	Level int
	// contains filtered or unexported fields
}

func (*Flate) Compress

func (f *Flate) Compress(in []byte) ([]byte, error)

func (*Flate) CompressStream

func (f *Flate) CompressStream(in io.Reader, out io.Writer) error

func (*Flate) Decompress

func (f *Flate) Decompress(in []byte) ([]byte, error)

func (*Flate) DecompressStream

func (f *Flate) DecompressStream(in io.Reader, out io.Writer) error

func (*Flate) GetLevel

func (f *Flate) GetLevel() int

func (*Flate) GetModes added in v0.1.0

func (f *Flate) GetModes() []int

func (*Flate) GetName added in v0.0.2

func (f *Flate) GetName() string

func (*Flate) SetLevel added in v0.0.2

func (f *Flate) SetLevel(level int)

type Gzip

type Gzip struct {
	Level int
	// contains filtered or unexported fields
}

func (*Gzip) Compress

func (g *Gzip) Compress(in []byte) ([]byte, error)

func (*Gzip) CompressStream

func (g *Gzip) CompressStream(in io.Reader, out io.Writer) error

func (*Gzip) Decompress

func (g *Gzip) Decompress(in []byte) ([]byte, error)

func (*Gzip) DecompressStream

func (g *Gzip) DecompressStream(in io.Reader, out io.Writer) error

func (*Gzip) GetLevel

func (g *Gzip) GetLevel() int

func (*Gzip) GetModes added in v0.1.0

func (g *Gzip) GetModes() []int

func (*Gzip) GetName added in v0.0.2

func (g *Gzip) GetName() string

func (*Gzip) SetLevel added in v0.0.2

func (g *Gzip) SetLevel(level int)

type Zlib

type Zlib struct {
	Level int
	// contains filtered or unexported fields
}

func (*Zlib) Compress

func (zl *Zlib) Compress(in []byte) ([]byte, error)

func (*Zlib) CompressStream

func (zl *Zlib) CompressStream(in io.Reader, out io.Writer) error

func (*Zlib) Decompress

func (zl *Zlib) Decompress(in []byte) ([]byte, error)

func (*Zlib) DecompressStream

func (zl *Zlib) DecompressStream(in io.Reader, out io.Writer) error

func (*Zlib) GetLevel

func (zl *Zlib) GetLevel() int

func (*Zlib) GetModes added in v0.1.0

func (zl *Zlib) GetModes() []int

func (*Zlib) GetName added in v0.0.2

func (zl *Zlib) GetName() string

func (*Zlib) SetLevel added in v0.0.2

func (zl *Zlib) SetLevel(level int)

type Zstd

type Zstd struct {
	Level int
	// contains filtered or unexported fields
}

func (*Zstd) Compress

func (z *Zstd) Compress(in []byte) ([]byte, error)

func (*Zstd) CompressStream

func (z *Zstd) CompressStream(in io.Reader, out io.Writer) error

func (*Zstd) Decompress

func (z *Zstd) Decompress(in []byte) ([]byte, error)

func (*Zstd) DecompressStream

func (z *Zstd) DecompressStream(in io.Reader, out io.Writer) error

func (*Zstd) GetLevel

func (z *Zstd) GetLevel() int

func (*Zstd) GetModes added in v0.1.0

func (z *Zstd) GetModes() []int

func (*Zstd) GetName added in v0.0.2

func (z *Zstd) GetName() string

func (*Zstd) SetLevel added in v0.0.2

func (z *Zstd) SetLevel(level int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL