Documentation ¶
Index ¶
- Constants
- func Compress(dst, src []byte) ([]byte, error)
- func CompressBound(srcSize int) int
- func CompressLevel(dst, src []byte, level int) ([]byte, error)
- func Decompress(dst, src []byte) ([]byte, error)
- func NewReader(r io.Reader) io.ReadCloser
- func NewReaderDict(r io.Reader, dict []byte) io.ReadCloser
- type ErrorCode
- type Writer
Constants ¶
const ( BestSpeed = 1 BestCompression = 20 )
Variables ¶
This section is empty.
Functions ¶
func Compress ¶
Compress src into dst. If you have a buffer to use, you can pass it to prevent allocation. If it is too small, or if nil is passed, a new buffer will be allocated and returned.
func CompressBound ¶
CompressBound returns the worst case size needed for a destination buffer, which can be used to preallocate a destination buffer or select a previously allocated buffer from a pool.
func CompressLevel ¶
CompressLevel is the same as Compress but you can pass a compression level
func Decompress ¶
Decompress src into dst. If you have a buffer to use, you can pass it to prevent allocation. If it is too small, or if nil is passed, a new buffer will be allocated and returned. By default, len(src) * 4 is allocated. If the buffer is too small, it will retry with a 2x sized dst buffer up to 3 times before falling back to the slower stream API (ie. if the compression ratio is 32).
func NewReader ¶
func NewReader(r io.Reader) io.ReadCloser
NewReader creates a new io.ReadCloser. Reads from the returned ReadCloser read and decompress data from r. It is the caller's responsibility to call Close on the ReadCloser when done. If this is not done, underlying objects in the zstd library will not be freed.
func NewReaderDict ¶
func NewReaderDict(r io.Reader, dict []byte) io.ReadCloser
NewReaderDict is like NewReader but uses a preset dictionary. NewReaderDict ignores the dictionary if it is nil.
Types ¶
type ErrorCode ¶
type ErrorCode int
ErrorCode is an error returned by the zstd library.
var ( ErrGeneric ErrorCode = -1 ErrPrefixUnknown ErrorCode = -2 ErrFrameParameterUnsupported ErrorCode = -3 ErrFrameParameterUnsupportedBy32bits ErrorCode = -4 ErrInitMissing ErrorCode = -5 ErrMemoryAllocation ErrorCode = -6 ErrStageWrong ErrorCode = -7 ErrDstSizeTooSmall ErrorCode = -8 ErrSrcSizeWrong ErrorCode = -9 ErrCorruptionDetected ErrorCode = -10 ErrTableLogTooLarge ErrorCode = -11 ErrMaxSymbolValueTooLarge ErrorCode = -12 ErrMaxSymbolValueTooSmall ErrorCode = -13 ErrDictionaryCorrupted ErrorCode = -14 ErrEmptySlice = errors.New("Bytes slice is empty") DefaultCompression = 5 )
type Writer ¶
type Writer struct { CompressionLevel int // contains filtered or unexported fields }
Writer is an io.WriteCloser that zstd-compresses its input.
func NewWriter ¶
NewWriter creates a new Writer with default compression options. Writes to the writer will be written in compressed form to w.
func NewWriterLevel ¶
NewWriterLevel is like NewWriter but specifies the compression level instead of assuming default compression.
The level can be DefaultCompression or any integer value between BestSpeed and BestCompression inclusive.
func NewWriterLevelDict ¶
NewWriterLevelDict is like NewWriterLevel but specifies a dictionary to compress with. If the dictionary is empty or nil it is ignored. The dictionary should not be modified until the writer is closed.