brotli-go.v0: gopkg.in/kothar/brotli-go.v0/dec Index | Examples | Files

package dec

import "gopkg.in/kothar/brotli-go.v0/dec"

Package dec provides Brotli decoder bindings

Index

Examples

Package Files

decode.go

func DecompressBuffer Uses

func DecompressBuffer(encodedBuffer []byte, decodedBuffer []byte) ([]byte, error)

DecompressBuffer decompress a Brotli-encoded buffer. Uses decodedBuffer as the destination buffer unless it is too small, in which case a new buffer is allocated. Returns the slice of the decodedBuffer containing the output, or an error.

func DecompressBufferDict Uses

func DecompressBufferDict(encodedBuffer []byte, inputDict []byte, decodedBuffer []byte) ([]byte, error)

DecompressBufferDict decompress a Brotli-encoded buffer. Uses decodedBuffer as the destination buffer unless it is too small, in which case a new buffer is allocated. Returns the slice of the decodedBuffer containing the output, or an error.

type BrotliReader Uses

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

BrotliReader decompresses a Brotli-encoded stream using the io.Reader interface

Code:

archiveReader, _ := os.Open("data.bin.bro")

brotliReader := NewBrotliReader(archiveReader)
defer brotliReader.Close()

decompressedWriter, _ := os.OpenFile("data.bin.unbro", os.O_CREATE|os.O_WRONLY, 0644)
defer decompressedWriter.Close()
io.Copy(decompressedWriter, brotliReader)

func NewBrotliReader Uses

func NewBrotliReader(stream io.Reader) *BrotliReader

NewBrotliReader returns a Reader that decompresses the stream from another reader.

Ensure that you Close the stream when you are finished in order to clean up the Brotli decompression state.

The internal decompression buffer defaults to 128kb

func NewBrotliReaderSize Uses

func NewBrotliReaderSize(stream io.Reader, size int) *BrotliReader

NewBrotliReaderSize is the same as NewBrotliReader, but allows the internal buffer size to be set.

The size of the internal buffer may be specified which will hold compressed data before being read by the decompressor

func (*BrotliReader) Close Uses

func (r *BrotliReader) Close() error

Close the reader and clean up any decompressor state.

func (*BrotliReader) Read Uses

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

Fill a buffer, p, with the decompressed contents of the stream. Returns the number of bytes read, or an error

Package dec imports 6 packages (graph) and is imported by 9 packages. Updated 2017-08-01. Refresh now. Tools for package owners.