Documentation ¶
Index ¶
Constants ¶
const ( // DefaultCodec defines the default comp.scheme. DefaultCodec = api.CompressionCodec_GZIP // MinBufferSize is the minimum size of the uncompressed buffer used by the // compressor and decompressor. MinBufferSize = uint32(64) // DefaultBufferSize is the default size of the uncompressed buffer used by // the compressor and decompressor. DefaultBufferSize = uint32(32 * 1024) )
Variables ¶
var ErrBufferSizeTooSmall = fmt.Errorf("buffer size is below %d byte minimum", MinBufferSize)
ErrBufferSizeTooSmall indicates when the max page size is too small (often because it is zero).
var MediaToCompressionCodec = map[string]api.CompressionCodec{ "application/x-gzip": api.CompressionCodec_NONE, "application/x-compressed": api.CompressionCodec_NONE, "application/x-zip-compressed": api.CompressionCodec_NONE, "application/zip": api.CompressionCodec_NONE, }
MediaToCompressionCodec maps MIME media types to what comp.codec should be used with them.
Functions ¶
func GetCompressionCodec ¶
func GetCompressionCodec(mediaType string) (api.CompressionCodec, error)
GetCompressionCodec returns the comp.codec to use given a MIME media type.
Types ¶
type CloseWriter ¶
type CloseWriter interface { io.Writer // Close writes any outstanding contents and additional footers. Close() error }
CloseWriter is an io.Writer that requires Close() to be called at the end of writing.
type Compressor ¶
type Compressor interface { io.Reader // UncompressedMAC is the MAC for the uncompressed bytes. UncompressedMAC() enc.MAC }
Compressor is an io.Reader with an enc.MAC on the uncompressed bytes.
func NewCompressor ¶
func NewCompressor( uncompressed io.Reader, codec api.CompressionCodec, keys *enc.EEK, uncompressedBufferSize uint32, ) (Compressor, error)
NewCompressor creates a new Compressor for the compressed contents using the given compression codec. Larger values of uncompressedBufferSize will result in fewer calls to the uncompressed io.Reader, at the expense of reading more than is needed into the internal buffer.
type Decompressor ¶
type Decompressor interface { CloseWriter // UncompressedMAC is the MAC for the uncompressed bytes. UncompressedMAC() enc.MAC }
Decompressor is a CloseWriter with an enc.MAC on the uncompressed bytes.
func NewDecompressor ¶
func NewDecompressor( uncompressed io.Writer, codec api.CompressionCodec, keys *enc.EEK, uncompressedBufferSize uint32, ) (Decompressor, error)
NewDecompressor creates a new Decompressor instance.
type FlushCloseWriter ¶
type FlushCloseWriter interface { CloseWriter // Flush flushes the contents to the underlying writer. Flush() error }
FlushCloseWriter is a CloseWriter with a Flush() method that can be called in between writes.