compression

package
v0.0.0-...-f0b4a20 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm int

Algorithm is the compression algorithm to use.

const (

	// Zstandard uses the zstd algorithm
	Zstandard Algorithm
	// DefaultAlgorithm is the default compression algorithm to use
	DefaultAlgorithm = Zstandard
)

func AutoDetect

func AutoDetect(r io.ReadSeeker) (Algorithm, error)

AutoDetect attempts to detect the compression algorithm used

func (Algorithm) Extension

func (c Algorithm) Extension() string

Extension returns the comprssion algorithm's file extension

func (Algorithm) MimeType

func (c Algorithm) MimeType() string

MimeType returns the compression algorithm's mime type

func (Algorithm) String

func (c Algorithm) String() string

type Compressor

type Compressor interface {
	io.WriteCloser
	Algorithm() Algorithm
}

Compressor is a generic interface for compressors

func NewCompressor

func NewCompressor(w io.Writer, a Algorithm, opts ...CompressorOption) (Compressor, error)

NewCompressor returns a new compressor

type CompressorOption

type CompressorOption interface {
	Apply(compressor interface{}) error
}

CompressorOption applies an option to a compressor

func WithCompressionLevel

func WithCompressionLevel(l Level) CompressorOption

WithCompressionLevel optionally sets the compression level

type Decompressor

type Decompressor interface {
	io.ReadCloser
	Algorithm() Algorithm
}

Decompressor is a generic interface for decompressors

func NewDecompressor

func NewDecompressor(r io.Reader, a Algorithm, opts ...DecompressorOption) (Decompressor, error)

NewDecompressor returns a new decompressor

type DecompressorOption

type DecompressorOption interface {
	Apply(decompressor interface{}) error
}

DecompressorOption applies an option to a decompressor

type Level

type Level int

Level defines the level of compression

const (

	// SpeedFastest will choose the fastest reasonable compression.
	SpeedFastest Level
	// SpeedDefault is the default "pretty fast" compression option.
	SpeedDefault
	// SpeedBetterCompression will yield better compression than the default.
	SpeedBetterCompression
	// SpeedBestCompression will choose the best available compression option.
	SpeedBestCompression
)

Jump to

Keyboard shortcuts

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