compression

package
v0.0.0-...-a504cba Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int
const (
	Default Level = iota
	Faster
	Better
)

type Provider

type Provider interface {
	// Return the max possible size for a compressed buffer given the uncompressed data size
	CompressMaxSize(originalSize int) int

	// Compress a []byte, the param is a []byte with the uncompressed content.
	// The reader/writer indexes will not be modified. The return is a []byte
	// with the compressed content.
	Compress(dst, src []byte) []byte

	// Decompress a []byte. The buffer needs to have been compressed with the matching Encoder.
	// The src is compressed content. If dst is passed, the decompressed data will be written there
	// The return were the result will be passed, if err is nil, the buffer was decompressed, no nil otherwise.
	Decompress(dst, src []byte, originalSize int) ([]byte, error)

	// Returns a new instance of the same provider, with the same exact configuration
	Clone() Provider

	// Close the compressor
	io.Closer
}

Provider is a interface of compression providers

func NewLz4Provider

func NewLz4Provider() Provider

NewLz4Provider return a interface of Provider.

func NewNoopProvider

func NewNoopProvider() Provider

NewNoopProvider returns a Provider interface that does not compress the data

func NewZLibProvider

func NewZLibProvider() Provider

NewZLibProvider returns a Provider interface

func NewZStdProvider

func NewZStdProvider(level Level) Provider

Jump to

Keyboard shortcuts

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