compression

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compressor

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

Compressor provides fast compression/decompression using zstd

func NewCompressor

func NewCompressor(cfg CompressorConfig) (*Compressor, error)

NewCompressor creates a new compressor instance

func (*Compressor) Close

func (c *Compressor) Close()

Close releases resources

func (*Compressor) Compress

func (c *Compressor) Compress(data []byte) ([]byte, error)

Compress compresses data and returns the compressed bytes Returns original data if compression doesn't reduce size

func (*Compressor) CompressWithHeader

func (c *Compressor) CompressWithHeader(data []byte) ([]byte, error)

CompressWithHeader compresses data and adds a header with original size Format: [compressed: 1 byte][originalSize: 4 bytes][compressedData: N bytes]

func (*Compressor) CompressionRatio

func (c *Compressor) CompressionRatio(data []byte) (float64, error)

CompressionRatio returns compression ratio for given data

func (*Compressor) Decompress

func (c *Compressor) Decompress(data []byte) ([]byte, error)

Decompress decompresses data

func (*Compressor) DecompressWithHeader

func (c *Compressor) DecompressWithHeader(data []byte) ([]byte, error)

DecompressWithHeader decompresses data with header

func (*Compressor) MinSize

func (c *Compressor) MinSize() int

MinSize returns the minimum size for compression

type CompressorConfig

type CompressorConfig struct {
	// Compression level (1-3, higher = better compression but slower)
	// 1 = Fastest, 2 = Default, 3 = Better compression
	Level int
	// MinSize is the minimum size to attempt compression
	// Data smaller than this won't be compressed
	MinSize int
}

CompressorConfig holds configuration for the compressor

func DefaultConfig

func DefaultConfig() CompressorConfig

DefaultConfig returns default compressor configuration

Jump to

Keyboard shortcuts

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