Documentation ¶
Index ¶
- Constants
- Variables
- func GetName(compressType uint16) string
- func NewBufferCompressor(size int) *bufferCompressor
- func NewGzipCompressor(opts ...GzipOpt) *gzipCompressor
- func NewZlibCompressor(opts ...ZlibOpt) *zlibCompressor
- func RegisterType(compressType uint16, compressName string) bool
- type Compressor
- type GzipCompressLevel
- type GzipOpt
- type SizeReader
- type SizeWriter
- type Type
- type ZlibOpt
Constants ¶
View Source
const (
DefaultBufferSize = 32 * 1024
)
View Source
const (
TypeNone = 0
)
View Source
const (
TypeZlib = 2
)
Variables ¶
View Source
var GzipOpts gzipOpts
View Source
var ZlibOpts zlibOpts
Functions ¶
func NewBufferCompressor ¶
func NewBufferCompressor(size int) *bufferCompressor
func NewGzipCompressor ¶
func NewGzipCompressor(opts ...GzipOpt) *gzipCompressor
func NewZlibCompressor ¶
func NewZlibCompressor(opts ...ZlibOpt) *zlibCompressor
func RegisterType ¶
Types ¶
type Compressor ¶
type Compressor interface { // 压缩类型 Type() Type // 将srcReader的数据压缩至dstWriter // 参数dstWriter:压缩数据写入的writer // 参数srcReader:原始数据读取的reader // 返回before:原始数据大小 // 返回after:压缩后数据大小 // 返回err:发生错误时返回,无错误返回nil Compress(dstWriter io.Writer, srcReader io.Reader) (before int64, after int64, err error) // 将srcReader的数据解压至dstWriter // 参数dstWriter:解压数据写入的writer // 参数srcReader:压缩数据读取的reader // 返回before:压缩数据大小 // 返回after:解压后数据大小 // 返回err:发生错误时返回,无错误返回nil Decompress(dstWriter io.Writer, srcReader io.Reader) (before int64, after int64, err error) }
type GzipCompressLevel ¶
type GzipCompressLevel int
const ( TypeGzip = 1 NoCompression GzipCompressLevel = gzip.NoCompression BestSpeed GzipCompressLevel = gzip.BestSpeed BestCompression GzipCompressLevel = gzip.BestCompression DefaultCompression GzipCompressLevel = gzip.DefaultCompression HuffmanOnly GzipCompressLevel = gzip.HuffmanOnly )
type SizeReader ¶
type SizeReader struct {
// contains filtered or unexported fields
}
func NewSizeReader ¶
func NewSizeReader(r io.Reader) *SizeReader
func (*SizeReader) Close ¶
func (r *SizeReader) Close() error
func (*SizeReader) Size ¶
func (r *SizeReader) Size() int64
type SizeWriter ¶
type SizeWriter struct {
// contains filtered or unexported fields
}
func NewSizeWriter ¶
func NewSizeWriter(w io.Writer) *SizeWriter
func (*SizeWriter) Close ¶
func (w *SizeWriter) Close() error
func (*SizeWriter) Size ¶
func (w *SizeWriter) Size() int64
Click to show internal directories.
Click to hide internal directories.