Documentation
¶
Overview ¶
Package gzipimpl provides a set of functions for compressing with zlib / zstd / gzip
Index ¶
- func New(req Requires) compression.Compressor
- type GzipStrategy
- func (s *GzipStrategy) Compress(src []byte) (result []byte, err error)
- func (s *GzipStrategy) CompressBound(sourceLen int) int
- func (s *GzipStrategy) ContentEncoding() string
- func (s *GzipStrategy) Decompress(src []byte) ([]byte, error)
- func (s *GzipStrategy) NewStreamCompressor(output *bytes.Buffer) compression.StreamCompressor
- type Requires
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GzipStrategy ¶
type GzipStrategy struct {
// contains filtered or unexported fields
}
GzipStrategy is the strategy for when serializer_compression_kind is gzip
func (*GzipStrategy) Compress ¶
func (s *GzipStrategy) Compress(src []byte) (result []byte, err error)
Compress will compress the data with gzip
func (*GzipStrategy) CompressBound ¶
func (s *GzipStrategy) CompressBound(sourceLen int) int
CompressBound returns the worst case size needed for a destination buffer when using gzip
The worst case expansion is a few bytes for the gzip file header, plus 5 bytes per 32 KiB block, or an expansion ratio of 0.015% for large files. The additional 18 bytes comes from the header (10 bytes) and trailer (8 bytes). There is no theoretical maximum to the header, but we don't set any extra header fields so it is safe to assume
Source: https://www.gnu.org/software/gzip/manual/html_node/Overview.html More details are in the linked RFC: https://www.ietf.org/rfc/rfc1952.txt
func (*GzipStrategy) ContentEncoding ¶
func (s *GzipStrategy) ContentEncoding() string
ContentEncoding returns the content encoding value for gzip
func (*GzipStrategy) Decompress ¶
func (s *GzipStrategy) Decompress(src []byte) ([]byte, error)
Decompress will decompress the data with gzip
func (*GzipStrategy) NewStreamCompressor ¶
func (s *GzipStrategy) NewStreamCompressor(output *bytes.Buffer) compression.StreamCompressor
NewStreamCompressor returns a new gzip Writer