Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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) (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
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 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) ([]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.