compressions

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupportedContentEncoding = errors.New("not supported content encoding")

Functions

This section is empty.

Types

type BaseReader

type BaseReader struct {
	// contains filtered or unexported fields
}

func (*BaseReader) Finish

func (this *BaseReader) Finish(obj Reader) error

func (*BaseReader) ResetFinish

func (this *BaseReader) ResetFinish()

func (*BaseReader) SetPool

func (this *BaseReader) SetPool(pool *ReaderPool)

type BaseWriter

type BaseWriter struct {
	// contains filtered or unexported fields
}

func (*BaseWriter) Finish

func (this *BaseWriter) Finish(obj Writer) error

func (*BaseWriter) ResetFinish

func (this *BaseWriter) ResetFinish()

func (*BaseWriter) SetPool

func (this *BaseWriter) SetPool(pool *WriterPool)

type BrotliReader

type BrotliReader struct {
	BaseReader
	// contains filtered or unexported fields
}

func (*BrotliReader) Close

func (this *BrotliReader) Close() error

func (*BrotliReader) RawClose

func (this *BrotliReader) RawClose() error

func (*BrotliReader) Read

func (this *BrotliReader) Read(p []byte) (n int, err error)

func (*BrotliReader) Reset

func (this *BrotliReader) Reset(reader io.Reader) error

type BrotliWriter

type BrotliWriter struct {
	BaseWriter
	// contains filtered or unexported fields
}

func (*BrotliWriter) Close

func (this *BrotliWriter) Close() error

func (*BrotliWriter) Flush

func (this *BrotliWriter) Flush() error

func (*BrotliWriter) Level

func (this *BrotliWriter) Level() int

func (*BrotliWriter) RawClose

func (this *BrotliWriter) RawClose() error

func (*BrotliWriter) Reset

func (this *BrotliWriter) Reset(newWriter io.Writer)

func (*BrotliWriter) Write

func (this *BrotliWriter) Write(p []byte) (int, error)

type ContentEncoding

type ContentEncoding = string
const (
	ContentEncodingBr      ContentEncoding = "br"
	ContentEncodingGzip    ContentEncoding = "gzip"
	ContentEncodingDeflate ContentEncoding = "deflate"
	ContentEncodingZSTD    ContentEncoding = "zstd"
)

func AllEncodings

func AllEncodings() []ContentEncoding

AllEncodings 当前支持的所有编码

type DeflateReader

type DeflateReader struct {
	BaseReader
	// contains filtered or unexported fields
}

func (*DeflateReader) Close

func (this *DeflateReader) Close() error

func (*DeflateReader) RawClose

func (this *DeflateReader) RawClose() error

func (*DeflateReader) Read

func (this *DeflateReader) Read(p []byte) (n int, err error)

func (*DeflateReader) Reset

func (this *DeflateReader) Reset(reader io.Reader) error

type DeflateWriter

type DeflateWriter struct {
	BaseWriter
	// contains filtered or unexported fields
}

func (*DeflateWriter) Close

func (this *DeflateWriter) Close() error

func (*DeflateWriter) Flush

func (this *DeflateWriter) Flush() error

func (*DeflateWriter) Level

func (this *DeflateWriter) Level() int

func (*DeflateWriter) RawClose

func (this *DeflateWriter) RawClose() error

func (*DeflateWriter) Reset

func (this *DeflateWriter) Reset(writer io.Writer)

func (*DeflateWriter) Write

func (this *DeflateWriter) Write(p []byte) (int, error)

type GzipReader

type GzipReader struct {
	BaseReader
	// contains filtered or unexported fields
}

func (*GzipReader) Close

func (this *GzipReader) Close() error

func (*GzipReader) RawClose

func (this *GzipReader) RawClose() error

func (*GzipReader) Read

func (this *GzipReader) Read(p []byte) (n int, err error)

func (*GzipReader) Reset

func (this *GzipReader) Reset(reader io.Reader) error

type GzipWriter

type GzipWriter struct {
	BaseWriter
	// contains filtered or unexported fields
}

func (*GzipWriter) Close

func (this *GzipWriter) Close() error

func (*GzipWriter) Flush

func (this *GzipWriter) Flush() error

func (*GzipWriter) Level

func (this *GzipWriter) Level() int

func (*GzipWriter) RawClose

func (this *GzipWriter) RawClose() error

func (*GzipWriter) Reset

func (this *GzipWriter) Reset(writer io.Writer)

func (*GzipWriter) Write

func (this *GzipWriter) Write(p []byte) (int, error)

type Reader

type Reader interface {
	Read(p []byte) (n int, err error)
	Reset(reader io.Reader) error
	RawClose() error
	Close() error

	SetPool(pool *ReaderPool)
	ResetFinish()
}

func NewBrotliReader

func NewBrotliReader(reader io.Reader) (Reader, error)

func NewDeflateReader

func NewDeflateReader(reader io.Reader) (Reader, error)

func NewGzipReader

func NewGzipReader(reader io.Reader) (Reader, error)

func NewReader

func NewReader(reader io.Reader, contentEncoding ContentEncoding) (Reader, error)

NewReader 获取Reader

func NewZSTDReader added in v0.4.9

func NewZSTDReader(reader io.Reader) (Reader, error)

type ReaderPool

type ReaderPool struct {
	// contains filtered or unexported fields
}

func NewReaderPool

func NewReaderPool(maxSize int, newFunc func(reader io.Reader) (Reader, error)) *ReaderPool

func (*ReaderPool) Get

func (this *ReaderPool) Get(parentReader io.Reader) (Reader, error)

func (*ReaderPool) Put

func (this *ReaderPool) Put(reader Reader)

type Writer

type Writer interface {
	Write(p []byte) (int, error)
	Flush() error
	Reset(writer io.Writer)
	RawClose() error
	Close() error
	Level() int

	SetPool(pool *WriterPool)
	ResetFinish()
}

func NewBrotliWriter

func NewBrotliWriter(writer io.Writer, level int) (Writer, error)

func NewDeflateWriter

func NewDeflateWriter(writer io.Writer, level int) (Writer, error)

func NewGzipWriter

func NewGzipWriter(writer io.Writer, level int) (Writer, error)

func NewWriter

func NewWriter(writer io.Writer, compressType serverconfigs.HTTPCompressionType, level int) (Writer, error)

NewWriter 获取Writer

func NewZSTDWriter added in v0.4.9

func NewZSTDWriter(writer io.Writer, level int) (Writer, error)

type WriterPool

type WriterPool struct {
	// contains filtered or unexported fields
}

func NewWriterPool

func NewWriterPool(maxSize int, maxLevel int, newFunc func(writer io.Writer, level int) (Writer, error)) *WriterPool

func (*WriterPool) Get

func (this *WriterPool) Get(parentWriter io.Writer, level int) (Writer, error)

func (*WriterPool) Put

func (this *WriterPool) Put(writer Writer)

type ZSTDReader added in v0.4.9

type ZSTDReader struct {
	BaseReader
	// contains filtered or unexported fields
}

func (*ZSTDReader) Close added in v0.4.9

func (this *ZSTDReader) Close() error

func (*ZSTDReader) RawClose added in v0.4.9

func (this *ZSTDReader) RawClose() error

func (*ZSTDReader) Read added in v0.4.9

func (this *ZSTDReader) Read(p []byte) (n int, err error)

func (*ZSTDReader) Reset added in v0.4.9

func (this *ZSTDReader) Reset(reader io.Reader) error

type ZSTDWriter added in v0.4.9

type ZSTDWriter struct {
	BaseWriter
	// contains filtered or unexported fields
}

func (*ZSTDWriter) Close added in v0.4.9

func (this *ZSTDWriter) Close() error

func (*ZSTDWriter) Flush added in v0.4.9

func (this *ZSTDWriter) Flush() error

func (*ZSTDWriter) Level added in v0.4.9

func (this *ZSTDWriter) Level() int

func (*ZSTDWriter) RawClose added in v0.4.9

func (this *ZSTDWriter) RawClose() error

func (*ZSTDWriter) Reset added in v0.4.9

func (this *ZSTDWriter) Reset(writer io.Writer)

func (*ZSTDWriter) Write added in v0.4.9

func (this *ZSTDWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL