package zstd
import "github.com/DataDog/zstd"
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 )
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.
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 ErrVersionUnsupported ErrorCode = -3 ErrParameterUnknown ErrorCode = -4 ErrFrameParameterUnsupported ErrorCode = -5 ErrFrameParameterUnsupportedBy32bits ErrorCode = -6 ErrFrameParameterWindowTooLarge ErrorCode = -7 ErrCompressionParameterUnsupported ErrorCode = -8 ErrCompressionParameterOutOfBound ErrorCode = -9 ErrInitMissing ErrorCode = -10 ErrMemoryAllocation ErrorCode = -11 ErrStageWrong ErrorCode = -12 ErrDstSizeTooSmall ErrorCode = -13 ErrSrcSizeWrong ErrorCode = -14 ErrCorruptionDetected ErrorCode = -15 ErrChecksumWrong ErrorCode = -16 ErrTableLogTooLarge ErrorCode = -17 ErrMaxSymbolValueTooLarge ErrorCode = -18 ErrMaxSymbolValueTooSmall ErrorCode = -19 ErrDictionaryCorrupted ErrorCode = -20 ErrDictionaryWrong ErrorCode = -21 ErrDictionaryCreationFailed ErrorCode = -22 ErrFrameIndexTooLarge ErrorCode = -23 ErrSeekableIO ErrorCode = -24 ErrMaxCode ErrorCode = -25 ErrEmptySlice = errors.New("Bytes slice is empty") DefaultCompression = 5 )
FIXME: this is very fragile, must map 1-to-1 with zstd's error_public.h. They have no problem with adding error codes, renumbering errors, etc.
func (ErrorCode) Error ¶
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.
func (*Writer) Close ¶
Close closes the Writer, flushing any unwritten data to the underlying io.Writer and freeing objects, but does not close the underlying io.Writer.
func (*Writer) Write ¶
Write writes a compressed form of p to the underlying io.Writer.
Source Files ¶
- Version
- v1.3.0
- Published
- Sep 7, 2017
- Platform
- darwin/amd64
- Imports
- 7 packages
- Last checked
- 1 week ago –
Tools for package owners.