compress

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: BSD-3-Clause Imports: 9 Imported by: 2 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMaxSizeCompressor = errors.New("invalid compressor max size")
	ErrDecompressedMsgTooLarge  = errors.New("decompressed msg too large")
	ErrMsgTooLarge              = errors.New("msg too large to be compressed")
)

Functions

This section is empty.

Types

type Compressor

type Compressor interface {
	Compress([]byte) ([]byte, error)
	Decompress([]byte) ([]byte, error)
}

Compressor compress and decompresses messages. Decompress is the inverse of Compress. Decompress(Compress(msg)) == msg.

func NewGzipCompressor

func NewGzipCompressor(maxSize int64) (Compressor, error)

NewGzipCompressor returns a new gzip Compressor that compresses

func NewNoCompressor

func NewNoCompressor() Compressor

type Type

type Type byte
const (
	TypeNone Type = iota + 1
	TypeZstd
)

func TypeFromString

func TypeFromString(s string) (Type, error)

func (Type) MarshalJSON

func (t Type) MarshalJSON() ([]byte, error)

func (Type) String

func (t Type) String() string

type ZstdCompressor

type ZstdCompressor struct {
	// contains filtered or unexported fields
}

ZstdCompressor implements Compressor using zstd compression

func NewZstdCompressor

func NewZstdCompressor(maxSize int64) (*ZstdCompressor, error)

func NewZstdCompressorWithLevel

func NewZstdCompressorWithLevel(maxSize int64, level zstd.EncoderLevel) (*ZstdCompressor, error)

func (*ZstdCompressor) Compress

func (z *ZstdCompressor) Compress(msg []byte) ([]byte, error)

func (*ZstdCompressor) Decompress

func (z *ZstdCompressor) Decompress(msg []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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