muxcodec

package
v0.0.0-...-ce94876 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: MIT, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoCodec = fmt.Errorf("no suitable codec")
)
View Source
var Header []byte

Functions

func CodecWithHeader

func CodecWithHeader(hdr []byte, codecs []mc.Multicodec) mc.Multicodec

func SelectFirst

func SelectFirst(v interface{}, codecs []mc.Multicodec) mc.Multicodec

SelectFirst is the default SelectCodec function. selects the first codec given.

Types

type Multicodec

type Multicodec struct {
	Codecs []mc.Multicodec // subcodecs to use
	Select SelectCodec     // pick a subcodec for encoding
	Wrap   bool            // whether to wrap with own header
	Last   mc.Multicodec   // the last subcodec used
}

func MuxMulticodec

func MuxMulticodec(codecs []mc.Multicodec, sel SelectCodec) *Multicodec

MuxMulticodec returns a multicodec that muxes between given codecs. It uses the given SelectCodec function when marshaling, to select the best codec to use.

func StandardMux

func StandardMux() *Multicodec

func (*Multicodec) Decoder

func (c *Multicodec) Decoder(r io.Reader) mc.Decoder

func (*Multicodec) Encoder

func (c *Multicodec) Encoder(w io.Writer) mc.Encoder

func (*Multicodec) Header

func (c *Multicodec) Header() []byte

type SelectCodec

type SelectCodec func(v interface{}, codecs []mc.Multicodec) mc.Multicodec

SelectCodec is a function that selects which codecs are able to marshal a given datastructure, and orders them (to be tried first).

Jump to

Keyboard shortcuts

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