compression

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAlgorithmName

func GetAlgorithmName(alg Algorithm) string

GetAlgorithmName returns the string name for an algorithm.

func IsAlgorithmSupported

func IsAlgorithmSupported(alg Algorithm) bool

IsAlgorithmSupported reports whether an algorithm is supported.

Types

type Algorithm

type Algorithm uint32

Algorithm represents the compression algorithm type.

const (
	AlgorithmNone   Algorithm = 0
	AlgorithmZstd   Algorithm = 100
	AlgorithmLz4    Algorithm = 200
	AlgorithmSnappy Algorithm = 300
	AlgorithmZlib   Algorithm = 400
)

func GetSupportedAlgorithms

func GetSupportedAlgorithms() []Algorithm

GetSupportedAlgorithms returns all supported algorithms.

type ErrorCode

type ErrorCode int

ErrorCode matches C++ compression error codes.

const (
	ErrorCodeOk           ErrorCode = 0
	ErrorCodeInvalidParam ErrorCode = -1
	ErrorCodeNotSupport   ErrorCode = -2
	ErrorCodeBufferSmall  ErrorCode = -3
	ErrorCodeOperation    ErrorCode = -4
	ErrorCodeDisabled     ErrorCode = -5
)

func Compress

func Compress(alg Algorithm, input []byte, level Level) ([]byte, ErrorCode)

Compress compresses input data using the given algorithm and level.

func CompressWithRawLevel

func CompressWithRawLevel(alg Algorithm, input []byte, rawLevel int) ([]byte, ErrorCode)

CompressWithRawLevel compresses input data using algorithm-specific raw level.

func Decompress

func Decompress(alg Algorithm, input []byte, originalSize int) ([]byte, ErrorCode)

Decompress decompresses input data using the given algorithm. originalSize is the expected size of the decompressed data; 0 means auto-detect when supported.

type Level

type Level int32

Level represents unified compression levels.

const (
	LevelDefault  Level = 0
	LevelStorage  Level = 100
	LevelFast     Level = 200
	LevelLowCPU   Level = 300
	LevelBalanced Level = 400
	LevelHighRate Level = 500
	LevelMaxRate  Level = 600
)

type MappedLevel

type MappedLevel struct {
	Level              int
	UseHighCompression bool
}

MappedLevel holds algorithm-specific parameters.

func MapCompressionLevel

func MapCompressionLevel(alg Algorithm, level Level) MappedLevel

MapCompressionLevel maps unified compression level to algorithm-specific settings.

Jump to

Keyboard shortcuts

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