Documentation
¶
Index ¶
Constants ¶
const ( BestSpeed = gzip.BestSpeed BestCompression = gzip.BestCompression BestestCompression = 12 DefaultCompression = gzip.DefaultCompression DefaultBufCap = 0x10000 )
These constants are copied from klauspost/compress/gzip. The BestCompression value is technically a lie for libdeflate--it goes all the way up to 12, not 9--so I've defined an extra constant for the real highest setting.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compressor ¶
type Compressor struct {
// contains filtered or unexported fields
}
Compressor is a minimal interface to libdeflate's compressor object.
func (*Compressor) Compress ¶
func (cc *Compressor) Compress(outData, inData []byte) int
Compress performs raw DEFLATE compression on a byte slice. outData[] must be large enough to fit the compressed data. Byte count of the compressed data is returned on success. Zero is currently returned on failure. A side effect is that inData cannot be length zero; this function will panic or crash if it is.
func (*Compressor) Init ¶
func (cc *Compressor) Init(compressionLevel int) error
Init allocates workspace needed by Compress().
type Decompressor ¶
type Decompressor struct {
// contains filtered or unexported fields
}
Decompressor is a minimal interface to libdeflate's decompressor object. It allocates a C memory area, so users are responsible for calling Decompressor.Cleanup() when done to avoid memory leaks. Multiple Decompressors can be active at once.
The Reader interface is not directly implemented here; instead, it is assumed that the user is decompressing a multi-block BGZF-like format, and they're fine with manual calls to Decompress().
func (*Decompressor) Decompress ¶
func (dd *Decompressor) Decompress(outData, inData []byte) (int, error)
Decompress performs raw DEFLATE decompression on a byte slice. outData[] must be large enough to fit the decompressed data. Byte count of the decompressed data is returned on success (it may be smaller than len(outData)).
func (*Decompressor) GzipDecompress ¶
func (dd *Decompressor) GzipDecompress(outData, inData []byte) (int, error)
GzipDecompress performs gzip decompression on a byte slice. outData[] must be large enough to fit the decompressed data. Byte count of the decompressed data is returned on success (it may be smaller than len(outData)).
func (*Decompressor) Init ¶
func (dd *Decompressor) Init() error
Init allocates workspace needed by Decompress().
type Writer ¶
A Writer is an io.WriteCloser. Writes to a Writer are compressed and written to w.
func NewWriter ¶
NewWriter returns a new Writer. Writes to the returned writer are compressed and written to w.
It is the caller's responsibility to call Close on the WriteCloser when done. Writes may be buffered and not flushed until Close.
Callers that wish to set the fields in Writer.Header must do so before the first call to Write, Flush, or Close.
func NewWriterLevel ¶
NewWriterLevel is like NewWriter but specifies the compression level instead of assuming DefaultCompression.
The compression level can be DefaultCompression, or any integer value between 1 and BestCompression inclusive. The error returned will be nil if the level is valid.
func (*Writer) Close ¶
Close closes the Writer, flushing any unwritten data to the underlying io.Writer, but does not close the underlying io.Writer.
func (*Writer) Reset ¶
Reset discards the Writer z's state and makes it equivalent to the result of its original state from NewWriter or NewWriterLevel, but writing to w instead. This permits reusing a Writer rather than allocating a new one.
It is safe to call Reset() without Close(). In this case, *no* bytes from the previous block are written.