compressor

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompressionType

type CompressionType string

CompressionType is the type identifying supported compression methods.

const (
	// NoOp is used to create a no-op Compressor.
	NoOp CompressionType = "no-op"
	// GZip is used to create a gzip-based Compressor.
	GZip CompressionType = "gzip"
)

type Compressor

type Compressor interface {
	// GetType returns the string type identifier of the compressor.
	GetType() string
	// Compress compresses a slice of bytes.
	Compress([]byte) ([]byte, error)
	// Decompress decompresses a slice of compressed bytes.
	Decompress([]byte) ([]byte, error)
}

Compressor declares the functionality provided by the different supported compressors.

func NewCompressor

func NewCompressor(compressionType CompressionType) (Compressor, error)

NewCompressor returns a compressor instance that corresponds to the given CompressionType.

type CompressorGZip

type CompressorGZip struct{}

CompressorGZip implements Compressor with gzip-based logic.

func (*CompressorGZip) Compress

func (compressor *CompressorGZip) Compress(data []byte) ([]byte, error)

Compress compresses a slice of bytes using gzip lib.

func (*CompressorGZip) Decompress

func (compressor *CompressorGZip) Decompress(compressedData []byte) ([]byte, error)

Decompress decompresses a slice of gzip-compressed bytes using gzip lib.

func (*CompressorGZip) GetType

func (compressor *CompressorGZip) GetType() string

GetType returns the string identifier for GZip compressor.

type CompressorNoOp

type CompressorNoOp struct{}

CompressorNoOp implements Compressor based on the No-Op pattern.

func (*CompressorNoOp) Compress

func (compressor *CompressorNoOp) Compress(data []byte) ([]byte, error)

Compress returns the bytes received as-is.

func (*CompressorNoOp) Decompress

func (compressor *CompressorNoOp) Decompress(data []byte) ([]byte, error)

Decompress returns the bytes received as-is.

func (*CompressorNoOp) GetType

func (compressor *CompressorNoOp) GetType() string

GetType returns the string identifier for no-op compressor.

Jump to

Keyboard shortcuts

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