codec

package
v0.0.0-...-dfdb87f Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCodec = defaultCodec{}

no-op codec

View Source
var ErrCodecNotFound = errors.New("codec not found")

Functions

func AESGCM

func AESGCM(key []byte) aeadCodec

func HybridCompressed

func HybridCompressed(
	compressType string,
	compress CompressFunc,
	uncompress UncompressFunc,
) hybridCompressedCodec

func HybridSnappy

func HybridSnappy() hybridCompressedCodec

func HybridZstd

func HybridZstd() hybridCompressedCodec

func NewAEADCodec

func NewAEADCodec(
	id string,
	newAEAD func() (cipher.AEAD, error),
) aeadCodec

func Segmented

func Segmented(
	wrapped Codec,
	cutSize int,
) segmentedCodec

func Snappy

func Snappy() snappyCodec

func Stacked

func Stacked(a, b Codec) stackedCodec

func TestCodecAESGCM

func TestCodecAESGCM(
	t *testing.T,
)

func TestCodecSnappy

func TestCodecSnappy(
	t *testing.T,
)

func TestCodecStacked

func TestCodecStacked(
	t *testing.T,
)

func TestHybridCompressed

func TestHybridCompressed(t *testing.T)

func TestHybridSnappy

func TestHybridSnappy(
	t *testing.T,
)

func TestHybridZstd

func TestHybridZstd(
	t *testing.T,
)

func TestOnion

func TestOnion(
	t *testing.T,
)

func TestOnion2

func TestOnion2(
	t *testing.T,
)

func TestSegmented

func TestSegmented(
	t *testing.T,
)

func TestSnappyStream

func TestSnappyStream(t *testing.T)

func UseSnappy

func UseSnappy() (string, CompressFunc, UncompressFunc)

func UseSnappyStream

func UseSnappyStream() (string, CompressFunc, UncompressFunc)

func UseZstd

func UseZstd() (string, CompressFunc, UncompressFunc)

Types

type Codec

type Codec interface {
	Encode(sb.Sink, ...Option) sb.Sink
	Decode(sb.Stream, ...Option) sb.Stream
	ID() string
}

type CompressFunc

type CompressFunc = func([]byte, io.Writer) error

type OnionCodec

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

func NewOnionCodec

func NewOnionCodec(
	encoders []Codec,
	decoders []Codec,
) OnionCodec

func (OnionCodec) Decode

func (o OnionCodec) Decode(stream sb.Stream, options ...Option) sb.Stream

func (OnionCodec) Encode

func (o OnionCodec) Encode(sink sb.Sink, options ...Option) sb.Sink

func (OnionCodec) ID

func (_ OnionCodec) ID() string

type Option

type Option interface {
	IsCodecOption()
}

type UncompressFunc

type UncompressFunc = func([]byte) ([]byte, error)

Jump to

Keyboard shortcuts

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