Documentation ¶
Index ¶
- func ZstdCompress(in io.Reader, out io.Writer, opts ...zstd.EOption) error
- func ZstdCompressBytes(src, dst []byte) []byte
- func ZstdDecompress(in io.Reader, out io.Writer, opts ...zstd.DOption) error
- func ZstdDecompressBytes(src, dst []byte) ([]byte, error)
- type CompressType
- type Compressor
- type Decompressor
- type ZstdCompressor
- type ZstdDecompressor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ZstdCompress ¶
Usa case: compress stream, large object only once This can be called concurrently Try ZstdCompressor for better efficiency if you need compress mutiple streams one by one
func ZstdCompressBytes ¶
Use case: compress small blocks This can be called concurrently
func ZstdDecompress ¶
Use case: decompress stream, large object only once This can be called concurrently Try ZstdDecompressor for better efficiency if you need decompress mutiple streams one by one
func ZstdDecompressBytes ¶
Use case: decompress small blocks This can be called concurrently
Types ¶
type CompressType ¶
type CompressType string
const ( CompressTypeZstd CompressType = "zstd" DefaultCompressAlgorithm CompressType = CompressTypeZstd )
type Compressor ¶
type Decompressor ¶
type ZstdCompressor ¶
type ZstdCompressor struct {
// contains filtered or unexported fields
}
func NewZstdCompressor ¶
For compressing small blocks, pass nil to the `out` parameter
func (*ZstdCompressor) Close ¶
func (c *ZstdCompressor) Close() error
The compressor is still re-used after calling this
func (*ZstdCompressor) Compress ¶
func (c *ZstdCompressor) Compress(in io.Reader) error
Use case: compress stream Call Close() to make sure the data is flushed to the underlying writer after the last Compress() call
func (*ZstdCompressor) CompressBytes ¶
func (c *ZstdCompressor) CompressBytes(src []byte, dst []byte) []byte
Use case: compress small blocks This compresses the src bytes and appends it to the dst bytes, then return the result This can be called concurrently
func (*ZstdCompressor) GetType ¶
func (c *ZstdCompressor) GetType() CompressType
func (*ZstdCompressor) ResetWriter ¶
func (c *ZstdCompressor) ResetWriter(out io.Writer)
Reset the writer to reuse the compressor
type ZstdDecompressor ¶
type ZstdDecompressor struct {
// contains filtered or unexported fields
}
func NewZstdDecompressor ¶
For compressing small blocks, pass nil to the `in` parameter
func (*ZstdDecompressor) Close ¶
func (dec *ZstdDecompressor) Close()
NOTICE: not like compressor, the decompressor is not usable after calling this
func (*ZstdDecompressor) Decompress ¶
func (dec *ZstdDecompressor) Decompress(out io.Writer) error
Usa case: decompress stream Write the decompressed data into `out`
func (*ZstdDecompressor) DecompressBytes ¶
func (dec *ZstdDecompressor) DecompressBytes(src []byte, dst []byte) ([]byte, error)
Use case: decompress small blocks This decompresses the src bytes and appends it to the dst bytes, then return the result This can be called concurrently
func (*ZstdDecompressor) GetType ¶
func (dec *ZstdDecompressor) GetType() CompressType
func (*ZstdDecompressor) ResetReader ¶
func (dec *ZstdDecompressor) ResetReader(in io.Reader)
Reset the reader to reuse the decompressor