encoders

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentDecoder

type ContentDecoder interface {
	Decode([]byte) ([]byte, error)
}

ContentDecoder removes a wrapper encoding from byte buffers.

func NewContentDecoder

func NewContentDecoder(encoding string) (ContentDecoder, error)

NewContentDecoder returns a ContentDecoder for the encoding type.

type ContentEncoder

type ContentEncoder interface {
	Encode([]byte) ([]byte, error)
}

ContentEncoder applies a wrapper encoding to byte buffers.

func NewContentEncoder

func NewContentEncoder(encoding string) (ContentEncoder, error)

NewContentEncoder returns a ContentEncoder for the encoding type.

type GzipDecoder

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

GzipDecoder decompresses buffers with gzip compression.

func NewGzipDecoder

func NewGzipDecoder() (*GzipDecoder, error)

func (*GzipDecoder) Decode

func (d *GzipDecoder) Decode(data []byte) ([]byte, error)

type GzipEncoder

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

GzipEncoder compresses the buffer using gzip at the default level.

func NewGzipEncoder

func NewGzipEncoder() (*GzipEncoder, error)

func (*GzipEncoder) Encode

func (e *GzipEncoder) Encode(data []byte) ([]byte, error)

Encode will take data passed in and encode it with GZip

func (*GzipEncoder) SetLevel

func (e *GzipEncoder) SetLevel(lvl int) error

SetLevel will change the gzip encoder compression level See https://golang.org/pkg/compress/gzip/#pkg-constants or a number between 0 and 9 0 being no compression 9 being best but slowest compression -1 is used to reset back to the default level

type IdentityDecoder

type IdentityDecoder struct{}

IdentityDecoder is a null decoder that returns the input.

func NewIdentityDecoder

func NewIdentityDecoder() *IdentityDecoder

func (*IdentityDecoder) Decode

func (*IdentityDecoder) Decode(data []byte) ([]byte, error)

type IdentityEncoder

type IdentityEncoder struct{}

IdentityEncoder is a null encoder that applies no transformation.

func NewIdentityEncoder

func NewIdentityEncoder() *IdentityEncoder

func (*IdentityEncoder) Encode

func (*IdentityEncoder) Encode(data []byte) ([]byte, error)

type SnappyEncoder

type SnappyEncoder struct{}

SnappyEncoder compresses and decompresses the buffer using google's snappy encryption.

func NewSnappyDecoder

func NewSnappyDecoder() (*SnappyEncoder, error)

NewSnappyDecoder returns a new snappy dencoder that can dencode []bytes previously encoded to []bytes.

func NewSnappyEncoder

func NewSnappyEncoder() (*SnappyEncoder, error)

NewSnappyEncoder returns a new snappy encoder that can encode []bytes to google snappy []bytes.

func (*SnappyEncoder) Decode

func (e *SnappyEncoder) Decode(data []byte) ([]byte, error)

Decode takes the passed in data and decodes it to a []byte. It can return an error if the data was encoded incorrectly.

func (*SnappyEncoder) Encode

func (e *SnappyEncoder) Encode(data []byte) ([]byte, error)

Encode take all data given to it and encodes it. Snappy will never return an error other than nil but returns nil to satisfy the Encode interface here.

Jump to

Keyboard shortcuts

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