brotli

package
v0.0.0-...-6b0313b Latest Latest
Warning

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

Go to latest
Published: May 7, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package brotli implements the brotli compressed data format.

Index

Constants

View Source
const (
	BestSpeed          = 0
	BestCompression    = 11
	DefaultCompression = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

func NewReader

func NewReader(r io.Reader) Reader

func (Reader) Read

func (b Reader) Read(p []byte) (n int, err error)

Read implements io.Reader, reading uncompressed bytes from its underlying Reader.

func (Reader) Reset

func (b Reader) Reset(r io.Reader)

Reset discards the Reader b's state and makes it equivalent to the result of its original state from NewReader, but reading from r instead. This permits reusing a Reader rather than allocating a new one.

type Writer

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

func NewWriter

func NewWriter(w io.Writer) Writer

NewWriter returns 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.

func NewWriterLevel

func NewWriterLevel(w io.Writer, level int) (Writer, error)

NewWriterLevel is like NewWriter but specifies the compression level instead of assuming DefaultCompression.

The compression level can be DefaultCompression or any integer value between BestSpeed and BestCompression inclusive. The error returned will be nil if the level is valid.

func (Writer) Close

func (b Writer) Close() error

Close closes the Writer by flushing any unwritten data to the underlying io.Writer. It does not close the underlying io.Writer.

func (Writer) Flush

func (b Writer) Flush() error

Flush flushes any pending compressed data to the underlying writer.

It is useful mainly in compressed network protocols, to ensure that a remote reader has enough data to reconstruct a packet. Flush does not return until the data has been written. If the underlying writer returns an error, Flush returns that error.

func (Writer) Reset

func (b Writer) Reset(w io.Writer)

Reset discards the Writer b's state and makes it equivalent to the result of its original state from NewWriter or NewWriterLevel, but writing to w instead. This permits reusing a Writer rather than allocating a new one.

func (Writer) Write

func (b Writer) Write(p []byte) (int, error)

Write writes a compressed form of p to the underlying io.Writer. The compressed bytes are not necessarily flushed until the Writer is closed.

Jump to

Keyboard shortcuts

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