pipe

package
v0.0.0-...-9431910 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pipe implements pipes which transform data, generally for compressing it.

This package includes the pipe "zlib", which compreses any value bigger than 100 bytes using the default zlib compression level. To tell compressed and uncompressed data apart, it prepends a byte to its output (0 for uncompressed, 1 for compressed).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, p *Pipe)

Register registers a new Pipe into the pipe registry. If there's already a Pipe with the same name, it will panic.

func RequiredImport

func RequiredImport(name string) string

RequiredImport returns the import required for using the pipe with the given name, or the empty string if the pipe is not known.

Types

type Pipe

type Pipe struct {
	// Encode passes the given data trough the pipe and produces
	// a new ouput. len(data) is always > 0.
	Encode func(data []byte) ([]byte, error)
	// Decode performs the inverse operation of Encode, producing
	// the original input to Encode from its output.
	// len(data) is always > 0.
	Decode func(data []byte) ([]byte, error)
}

Pipe represents a codec pipe, which can encode and decode data as it's saved to or loaded from the database.

func FromTag

func FromTag(t *structs.Tag) *Pipe

FromTag returns the pipe for a given field tag.

func Get

func Get(name string) *Pipe

Get returns the Pipe with the give name, or nil if there's no such Pipe.

Jump to

Keyboard shortcuts

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