snappy

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package snappy provides a reader and writer that propagate calls to Flush and Close.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadResetter

type ReadResetter interface {
	io.Reader
	Resetter
}

func ReadBytes

func ReadBytes(b []byte) ReadResetter

ReadBytes returns a reader for reading snappy-compressed bytes from an input slice. b is the input slice of compressed bytes.

type Reader

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

func NewReader

func NewReader(r io.ReadCloser) *Reader

NewReader returns a new Reader that decompresses from r, using the framing format described at https://github.com/google/snappy/blob/master/framing_format.txt

func ReadFile

func ReadFile(path string, bufferSize int) (*Reader, error)

ReadFile returns a reader for a snappy-compressed file, and an error if any.

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

func (*Reader) Reset

func (r *Reader) Reset(reader io.ReadCloser)

type Resetter

type Resetter interface {
	Reset(reader io.Reader)
}

type Writer

type Writer struct {
	*snappy.Writer
	// contains filtered or unexported fields
}

func NewBufferedWriter

func NewBufferedWriter(w io.WriteCloser) *Writer

NewBufferedWriter returns a new Writer that compresses to w, using the framing format described at https://github.com/google/snappy/blob/master/framing_format.txt

The Writer returned buffers writes. Users must call Close to guarantee all data has been forwarded to the underlying io.Writer. They may also call Flush zero or more times before calling Close.

func WriteFile

func WriteFile(path string, bufferSize int) (*Writer, error)

WriteFile returns a Writer for writing to a local file

func (*Writer) Close

func (w *Writer) Close() error

Close closes the snppy.Writer, and then flushes and closes the underlying io.WriteCloser.

func (*Writer) Flush

func (w *Writer) Flush() error

Flush writes any pending data to the underlying io.Writer. Then calls the "Flush() error" method of the underlying writer, if it implements it.

func (*Writer) Reset

func (w *Writer) Reset(writer io.WriteCloser)

Reset discards the writer's state and switches the Snappy writer to write to w. This permits reusing a Writer rather than allocating a new one

Jump to

Keyboard shortcuts

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