Documentation ¶
Index ¶
- Variables
- type CompressorManager
- func (c *CompressorManager) BrotliCompress(data []byte) ([]byte, error)
- func (c *CompressorManager) BrotliDecompress(data []byte) ([]byte, error)
- func (c *CompressorManager) Compress(tp ContentEncoding, data []byte) ([]byte, error)
- func (c *CompressorManager) Decompress(tp ContentEncoding, data []byte) ([]byte, error)
- func (c *CompressorManager) GzipCompress(data []byte) ([]byte, error)
- func (c *CompressorManager) GzipDecompress(data []byte) ([]byte, error)
- func (c *CompressorManager) ZlibCompress(data []byte) ([]byte, error)
- func (c *CompressorManager) ZlibDecompress(data []byte) ([]byte, error)
- type ContentEncoding
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnknownContentEncoding = errors.New("[RRPC] uknown content encoding")
)
ErrUnknownContentEncoding is an error indicating an unknown content encoding.
Functions ¶
This section is empty.
Types ¶
type CompressorManager ¶
type CompressorManager struct {
// contains filtered or unexported fields
}
CompressorManager is a manager for compressors.
func NewCompressorManager ¶
func NewCompressorManager() *CompressorManager
NewCompressorManager creates a new instance of CompressorManager. CompressorManager manages the pools for byte readers and various compressors.
func (*CompressorManager) BrotliCompress ¶
func (c *CompressorManager) BrotliCompress(data []byte) ([]byte, error)
BrotliCompress compresses the given data using the Brotli compression algorithm. It returns the compressed data as a byte slice. If an error occurs during compression, it returns nil and the error.
func (*CompressorManager) BrotliDecompress ¶
func (c *CompressorManager) BrotliDecompress(data []byte) ([]byte, error)
BrotliDecompress Decompresses the given data using Brotli compression algorithm. It takes a byte slice as input and returns the Decompressed data as a byte slice. If an error occurs during the Decompression process, it returns the error.
func (*CompressorManager) Compress ¶
func (c *CompressorManager) Compress(tp ContentEncoding, data []byte) ([]byte, error)
Compress compresses the given data using the specified content encoding. It returns the compressed data and an error, if any. If the data is nil, it returns nil, nil. The supported content encodings are Gzip, Deflate, Brotli, and Plain. If an unknown content encoding is provided, it returns nil and an error.
func (*CompressorManager) Decompress ¶
func (c *CompressorManager) Decompress(tp ContentEncoding, data []byte) ([]byte, error)
Decompress Decompresses the given data using the specified content encoding. It returns the Decompressed data and an error, if any. The supported content encodings are Gzip, Deflate, Brotli, and Plain. If the data is nil, it returns nil, nil. If the content encoding is unknown, it returns nil and an ErrUnknownContentEncoding error.
func (*CompressorManager) GzipCompress ¶
func (c *CompressorManager) GzipCompress(data []byte) ([]byte, error)
GzipCompress compresses the given data using gzip compression algorithm. It returns the compressed data as a byte slice and an error if any occurred.
func (*CompressorManager) GzipDecompress ¶
func (c *CompressorManager) GzipDecompress(data []byte) ([]byte, error)
GzipDecompress Decompresses the given data using Gzip compression algorithm. It takes a byte slice as input and returns the Decompressed data as a byte slice. If an error occurs during the Decompression process, it returns the error.
func (*CompressorManager) ZlibCompress ¶
func (c *CompressorManager) ZlibCompress(data []byte) ([]byte, error)
ZlibCompress compresses the given data using the zlib compression algorithm. It returns the compressed data as a byte slice. If an error occurs during compression, it returns nil and the error.
func (*CompressorManager) ZlibDecompress ¶
func (c *CompressorManager) ZlibDecompress(data []byte) ([]byte, error)
ZlibDecompress Decompresses the given data using the zlib compression algorithm. It returns the Decompressed data and any error encountered during the Decompression process.
type ContentEncoding ¶
type ContentEncoding int
ContentEncoding represents the encoding type used for compressing content.
const ( ContentEncodingGzip ContentEncoding = 0 ContentEncodingDeflate ContentEncoding = 1 ContentEncodingBrotli ContentEncoding = 2 ContentEncodingPlain ContentEncoding = 3 )