Documentation
¶
Index ¶
- Constants
- type Reader
- type Resetter
- type Writer
- func NewWriter(w io.Writer) *Writer
- func NewWriterLevel(w io.Writer, level int) (*Writer, error)
- func NewWriterLevelDict(w io.Writer, level int, dict []byte) (*Writer, error)
- func NewWriterLevelStrategy(w io.Writer, level, strategy int) (*Writer, error)
- func NewWriterLevelStrategyDict(w io.Writer, level, strategy int, dict []byte) (*Writer, error)
Constants ¶
const ( //NoCompression does not compress given input NoCompression = 0 //BestSpeed is fastest but with lowest compression BestSpeed = 1 //BestCompression is slowest but with best compression BestCompression = 9 //DefaultCompression is a compromise between BestSpeed and BestCompression. //The level might change if algorithms change. DefaultCompression = -1 // Filtered is more effective for small (but not all too many) randomly distributed values. // It forces more Huffman encoding. Use it for filtered data. It's between Default and Huffman only. Filtered = 1 //HuffmanOnly only uses Huffman encoding to compress the given data HuffmanOnly = 2 //RLE (run-length encoding) limits match distance to one, thereby being almost as fast as HuffmanOnly // but giving better compression for PNG data. RLE = 3 //Fixed disallows dynamic Huffman codes, thereby making it a simpler decoder Fixed = 4 // DefaultStrategy is the default compression strategy that should be used for most appliances DefaultStrategy = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader decompresses data from an underlying io.Reader or via the ReadBytes method, which should be preferred
func NewReader ¶
NewReader returns a new reader, reading from r. It decompresses read data. r may be nil if you only plan on using ReadBytes
func NewReaderDict ¶
NewReaderDict does exactly like NewReader as of NOW. This will change once custom dicionaries are implemented. This function has been added for compatibility with the std lib.
func (*Reader) Close ¶
Close closes the Reader by closing and freeing the underlying zlib stream. You should not forget to call this after being done with the writer.
func (*Reader) Read ¶
Read reads compressed data from the provided Reader into the provided buffer p. Please consider using ReadBytes instead, as it is slightly faster and generally easier to use
func (*Reader) ReadBytes ¶
ReadBytes takes compressed data p, decompresses it and returns it as new byte slice. It also returns the number n of bytes that were processed from the compressed slice. If n < len(compressed) and err == nil then only the first n compressed bytes were in a suitable zlib format and as such decompressed. This method is generally slightly faster than Read.
func (*Reader) Reset ¶
Reset resets the Reader to the state of being initialized with zlib.NewX(..), but with the new underlying reader instead. It allows for reuse of the same reader. AS OF NOW dict IS NOT USED. It's just there to implement the Resetter interface to allow for easy interchangeablility with the std lib. Just pass nil.
type Resetter ¶
type Resetter interface {
// Reset resets the Reader to the state of being initialized with zlib.NewX(..),
// but with the new underlying reader and dict instead. It allows for reuse of the same reader.
Reset(r io.Reader, dict []byte) error
}
Resetter resets the zlib.Reader returned by NewReader by assigning a new underyling reader, discarding any buffered data from the previous reader. This interface is mainly for compatibility with the std lib
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer compresses and writes given data to an underlying io.Writer
func NewWriter ¶
NewWriter returns a new Writer with the underlying io.Writer to compress to. w may be nil if you only plan on using WriteBytes. Panics if the underlying c stream cannot be allocated which would indicate a severe error not only for this library but also for the rest of your code.
func NewWriterLevel ¶
NewWriterLevel performs like NewWriter but you may also specify the compression level. w may be nil if you only plan on using WriteBytes.
func NewWriterLevelDict ¶
NewWriterLevelDict does exactly like NewWriterLevel as of NOW. This will change once custom dicionaries are implemented. This function has been added for compatibility with the std lib.
func NewWriterLevelStrategy ¶
NewWriterLevelStrategy performs like NewWriter but you may also specify the compression level and strategy. w may be nil if you only plan on using WriteBytes.
func NewWriterLevelStrategyDict ¶
NewWriterLevelStrategyDict does exactly like NewWriterLevelStrategy as of NOW. This will change once custom dicionaries are implemented. This function has been added mainly for completeness' sake.
func (*Writer) Close ¶
Close closes the writer by flushing any unwritten data to the underlying writer. You should not forget to call this after being done with the writer.
func (*Writer) Flush ¶
Flush does NOTHING. Write always flushes content to the underlying writer. This method just exists for easy interchangeability with the go std zlib library
func (*Writer) Reset ¶
Reset resets the Writer to the state of being initialized with zlib.NewX(..), but with the new underlying writer instead. This will panic if the writer has already been closed