compression

package
v0.1.0-util Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoopProvider = NewNoopProvider()
	ZLibProvider = NewZLibProvider()
	Lz4Provider  = NewLz4Provider()
	ZStdProvider = NewZStdProvider()
)

Functions

This section is empty.

Types

type Provider

type Provider interface {
	// CanCompress checks if the compression method is available under the current version.
	CanCompress() bool

	// 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(data []byte) []byte

	// Decompress a []byte. The buffer needs to have been compressed with the matching Encoder.
	// The compressedData is compressed content, originalSize is the size of the original content.
	// The return were the result will be passed, if err is nil, the buffer was decompressed, no nil otherwise.
	Decompress(compressedData []byte, originalSize int) ([]byte, error)
}

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

func NewZLibProvider

func NewZLibProvider() Provider

NewZLibProvider returns a Provider interface

func NewZStdProvider

func NewZStdProvider() Provider

Jump to

Keyboard shortcuts

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