Namespace: go.std.compress.zlib
v1.0Contents
Summary
Provides a low-level interface to the compress/zlib package.
Package zlib implements reading and writing of zlib format compressed data,
as specified in RFC 1950.
The implementation provides filters that uncompress during reading
and compress during writing. For example, to write compressed data
to a buffer:
var b bytes.Buffer
w := zlib.NewWriter(&b)
w.Write([]byte("hello, world\n"))
w.Close()
and to read that data back:
r, err := zlib.NewReader(&b)
io.Copy(os.Stdout, r)
r.Close()
Index
- *Writer
- BestCompression
- BestSpeed
- DefaultCompression
- ErrChecksum
- ErrDictionary
- ErrHeader
- HuffmanOnly
- NewReader
- NewReaderDict
- NewWriter
- NewWriterLevel
- NewWriterLevelDict
- NoCompression
- Resetter
- Writer
- arrayOfResetter
- arrayOfWriter
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
BestCompression
Int v1.0These constants are copied from the flate package, so that code that imports
"compress/zlib" does not also have to import "compress/flate".
-
BestSpeed
Int v1.0These constants are copied from the flate package, so that code that imports
"compress/zlib" does not also have to import "compress/flate".
-
DefaultCompression
Int v1.0These constants are copied from the flate package, so that code that imports
"compress/zlib" does not also have to import "compress/flate".
-
HuffmanOnly
Int v1.0These constants are copied from the flate package, so that code that imports
"compress/zlib" does not also have to import "compress/flate".
-
NoCompression
Int v1.0These constants are copied from the flate package, so that code that imports
"compress/zlib" does not also have to import "compress/flate".
Variables
-
ErrChecksum
Var v1.0ErrChecksum is returned when reading ZLIB data that has an invalid checksum.
-
ErrDictionary
Var v1.0ErrDictionary is returned when reading ZLIB data that has an invalid dictionary.
-
ErrHeader
Var v1.0ErrHeader is returned when reading ZLIB data that has an invalid header.
Functions, Macros, and Special Forms
-
NewReader
Function v1.0(NewReader r)
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.
Go input arguments: (r io.Reader)
Go returns: (io.ReadCloser, error)
Joker input arguments: [^go.std.io/Reader r]
Joker returns: [^go.std.io/ReadCloser, ^Error] -
NewReaderDict
Function v1.0(NewReaderDict r dict)
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.
Go input arguments: (r io.Reader, dict []byte)
Go returns: (io.ReadCloser, error)
Joker input arguments: [^go.std.io/Reader r, ^arrayOfByte dict]
Joker returns: [^go.std.io/ReadCloser, ^Error] -
NewWriter
Function v1.0(NewWriter w)
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.
Go input arguments: (w io.Writer)
Go returns: *Writer
Joker input arguments: [^go.std.io/Writer w]
Joker returns: ^*Writer -
NewWriterLevel
Function v1.0(NewWriterLevel w level)
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.
Go input arguments: (w io.Writer, level int)
Go returns: (*Writer, error)
Joker input arguments: [^go.std.io/Writer w, ^Int level]
Joker returns: [^*Writer, ^Error] -
NewWriterLevelDict
Function v1.0(NewWriterLevelDict w level dict)
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.
Go input arguments: (w io.Writer, level int, dict []byte)
Go returns: (*Writer, error)
Joker input arguments: [^go.std.io/Writer w, ^Int level, ^arrayOfByte dict]
Joker returns: [^*Writer, ^Error]
Types
-
*Writer
Concrete Type v1.0A Writer takes data written to it and writes the compressed
form of that data to an underlying writer (see NewWriter).
-
Close
Receiver for *Writer v1.0([])
Close closes the Writer, flushing any unwritten data to the underlying
io.Writer, but does not close the underlying io.Writer.
-
Flush
Receiver for *Writer v1.0([])
Flush flushes the Writer to its underlying io.Writer.
-
Reset
Receiver for *Writer v1.0([w])
Reset clears the state of the Writer z such that it is equivalent to its
initial state from NewWriterLevel or NewWriterLevelDict, but instead writing
to w.
-
Write
Receiver for *Writer v1.0([p])
Write writes a compressed form of p to the underlying io.Writer. The
compressed bytes are not necessarily flushed until the Writer is closed or
explicitly flushed.
-
Resetter
Abstract Type v1.0Resetter resets a ReadCloser returned by NewReader or NewReaderDict
to switch to a new underlying Reader. This permits reusing a ReadCloser
instead of allocating a new one.
-
Reset
Method for Resetter v1.0([r dict])
-
Writer
Concrete Type v1.0A Writer takes data written to it and writes the compressed
form of that data to an underlying writer (see NewWriter).
-
arrayOfResetter
Concrete Type v1.0Resetter resets a ReadCloser returned by NewReader or NewReaderDict
to switch to a new underlying Reader. This permits reusing a ReadCloser
instead of allocating a new one.
-
arrayOfWriter
Concrete Type v1.0A Writer takes data written to it and writes the compressed
form of that data to an underlying writer (see NewWriter).