Documentation
¶
Index ¶
- type Compressor
- func (c *Compressor) Close()
- func (c *Compressor) Compress(data []byte) ([]byte, error)
- func (c *Compressor) CompressWithHeader(data []byte) ([]byte, error)
- func (c *Compressor) CompressionRatio(data []byte) (float64, error)
- func (c *Compressor) Decompress(data []byte) ([]byte, error)
- func (c *Compressor) DecompressWithHeader(data []byte) ([]byte, error)
- func (c *Compressor) MinSize() int
- type CompressorConfig
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) 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