Documentation ¶
Overview ¶
Package zlib provides a writer that embeds the standard library zlib.Writer and propagates calls to Flush and Close.
Package zlib provides a reader and writer that propagate calls to Flush and Close.
Index ¶
- Constants
- type ByteReadCloser
- type ReadResetCloser
- type Reader
- type Resetter
- type Writer
- func NewWriter(w io.WriteCloser) *Writer
- func NewWriterDict(w io.WriteCloser, dict []byte) (*Writer, error)
- func NewWriterLevel(w io.WriteCloser, level int) (*Writer, error)
- func NewWriterLevelDict(w io.WriteCloser, level int, dict []byte) (*Writer, error)
- func WriteFile(path string, dict []byte, bufferSize int) (*Writer, error)
Constants ¶
const ( NoCompression = zlib.NoCompression BestSpeed = zlib.BestSpeed BestCompression = zlib.BestCompression DefaultCompression = zlib.DefaultCompression HuffmanOnly = zlib.HuffmanOnly )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteReadCloser ¶
type ByteReadCloser interface { io.ReadCloser io.ByteReader }
type ReadResetCloser ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func NewReader ¶
func NewReader(r ByteReadCloser) (*Reader, error)
NewReader creates a new ReadCloser. Reads from the returned ReadCloser read and decompress data from r. If r does not implement io.ByteReader, the decompressor may read more data than necessary from r. It is the caller's responsibility to call Close on the ReadCloser when done.
The ReadCloser returned by NewReader also implements Resetter.
func NewReaderDict ¶
func NewReaderDict(r ByteReadCloser, dict []byte) (*Reader, error)
NewReaderDict is like NewReader but uses a preset dictionary. NewReaderDict ignores the dictionary if the compressed data does not refer to it. If the compressed data refers to a different dictionary, NewReaderDict returns ErrDictionary.
The ReadCloser returned by NewReaderDict also implements Resetter.
type Writer ¶
func NewWriter ¶
func NewWriter(w io.WriteCloser) *Writer
NewWriter creates a new Writer. Writes to the returned Writer are compressed and written to w.
It is the caller's responsibility to call Close on the Writer when done. Writes may be buffered and not flushed until Close.
func NewWriterDict ¶
func NewWriterDict(w io.WriteCloser, dict []byte) (*Writer, error)
NewWriterDict is like NewWriter but specifies a dictionary to compress with.
The dictionary may be nil. If not, its contents should not be modified until the Writer is closed.
func NewWriterLevel ¶
func NewWriterLevel(w io.WriteCloser, level int) (*Writer, error)
NewWriterLevel is like NewWriter but specifies the compression level instead of assuming DefaultCompression.
The compression level can be DefaultCompression, NoCompression, HuffmanOnly or any integer value between BestSpeed and BestCompression inclusive. The error returned will be nil if the level is valid.
func NewWriterLevelDict ¶
NewWriterLevelDict is like NewWriterLevel but specifies a dictionary to compress with.
The dictionary may be nil. If not, its contents should not be modified until the Writer is closed.