dec

package
v0.0.0-...-771231d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2017 License: MIT Imports: 6 Imported by: 25

Documentation

Overview

Package dec provides Brotli decoder bindings

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecompressBuffer

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

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.

Types

type BrotliReader

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

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

Example
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)
Output:

func NewBrotliReader

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

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

func (r *BrotliReader) Close() error

Close the reader and clean up any decompressor state.

func (*BrotliReader) Read

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL