Documentation ¶
Index ¶
- Constants
- func Adler32(adler32 uint32, in []byte) uint32
- func CompressDEFLATE(c *C.comp, inAddr, outAddr *byte, inSize, outSize int) int
- func CompressGzip(c *C.comp, inAddr, outAddr *byte, inSize, outSize int) int
- func CompressZlib(c *C.comp, inAddr, outAddr *byte, inSize, outSize int) int
- func Crc32(crc32 uint32, in []byte) uint32
- func DecompressDEFLATE(dc *C.decomp, inAddr, outAddr *byte, inSize, outSize int, ...) error
- func DecompressGzip(dc *C.decomp, inAddr, outAddr *byte, inSize, outSize int, ...) error
- func DecompressZlib(dc *C.decomp, inAddr, outAddr *byte, inSize, outSize int, ...) error
- func DeflateBound(c *C.comp, s int) int
- func GzipBound(c *C.comp, s int) int
- func ZlibBound(c *C.comp, s int) int
- type Compressor
- type Decompressor
Constants ¶
const ( MinCompressionLevel = 1 MaxStdZlibCompressionLevel = 9 MaxCompressionLevel = 12 DefaultCompressionLevel = 6 )
Variables ¶
This section is empty.
Functions ¶
func CompressDEFLATE ¶
CompressDEFLATE interfaces with c libdeflate for DEFLATE compression
func CompressGzip ¶
CompressGzip interfaces with c libdeflate for gzip compression
func CompressZlib ¶
CompressZlib interfaces with c libdeflate for zlib compression
func DecompressDEFLATE ¶
func DecompressDEFLATE(dc *C.decomp, inAddr, outAddr *byte, inSize, outSize int, consPtr, sPtr uintptr) error
DecompressDEFLATE interfaces with c libdeflate for DEFLATE decompression
func DecompressGzip ¶
func DecompressGzip(dc *C.decomp, inAddr, outAddr *byte, inSize, outSize int, consPtr, sPtr uintptr) error
DecompressGzip interfaces with c libdeflate for gzip decompression
func DecompressZlib ¶
func DecompressZlib(dc *C.decomp, inAddr, outAddr *byte, inSize, outSize int, consPtr, sPtr uintptr) error
DecompressZlib interfaces with c libdeflate for zlib decompression
func DeflateBound ¶
DeflateBound works as described in native/libs/libdeflate.h
Types ¶
type Compressor ¶
type Compressor struct {
// contains filtered or unexported fields
}
Compressor compresses data to zlib format at the specified level
func NewCompressor ¶
func NewCompressor(lvl int) (*Compressor, error)
NewCompressor returns a new Compressor used to compress data. Errors if out of memory or invalid lvl
func (*Compressor) Close ¶
func (c *Compressor) Close()
Close frees the memory allocated by C objects
func (*Compressor) Compress ¶
func (c *Compressor) Compress(in, out []byte, f compress) (int, []byte, error)
Compress compresses the data from in to out and returns the number of bytes written to out, out and an error if the out buffer was too short. If you pass nil for out, this function will allocate a fitting buffer and return it.
Notice that for extremely small or already highly compressed data, the compressed data could be larger than uncompressed. If out == nil: For a too large discrepancy (len(out) > 1000 + 2 * len(in)) Compress will error
func (*Compressor) PanicFreeClose ¶ added in v2.2.0
func (c *Compressor) PanicFreeClose()
PanicFreeClose is like Close but doesn't panic if the compressor is already closed. This is useful for the higher-level autoclose functionality.
func (*Compressor) UpperBound ¶
func (c *Compressor) UpperBound(size int, f bound) int
UpperBound works as described in native/libs/libdeflate.h
type Decompressor ¶
type Decompressor struct {
// contains filtered or unexported fields
}
Decompressor decompresses any DEFLATE, zlib or gzip compressed data at any level
func NewDecompressor ¶
func NewDecompressor() (*Decompressor, error)
NewDecompressor returns a new Decompressor with maxDecompressionFactor = 30 or and error if out of memory
func NewDecompressorWithExtendedDecompression ¶ added in v2.0.3
func NewDecompressorWithExtendedDecompression(maxDecompressionFactor int) (*Decompressor, error)
NewDecompressorWithExtendedDecompression returns a new Decompressor with maxDecompressionFactor or and error if out of memory
func (*Decompressor) Close ¶
func (dc *Decompressor) Close()
Close frees the memory allocated by C objects
func (*Decompressor) Decompress ¶
func (dc *Decompressor) Decompress(in, out []byte, f decompress) (int, []byte, error)
Decompress decompresses the given data from in to out and returns out and an error if something went wrong. If error != nil, then the data in out is undefined. If you pass a buffer to out, the size of this buffer must exactly match the length of the decompressed data. If you pass nil as out, this function will allocate a sufficient buffer and return it. Returns the number of consumed bytes from 'in'
func (*Decompressor) PanicFreeClose ¶ added in v2.2.0
func (c *Decompressor) PanicFreeClose()
PanicFreeClose is like Close but doesn't panic if the decompressor is already closed. This is useful for the higher-level autoclose functionality.