codec

package
v1.0.6-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultTagName that enables serialization.
	DefaultTagName = "serialize"

	// TagValue is the value the tag must have to be serialized.
	TagValue = "true"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Registry
	MarshalInto(interface{}, *wrappers.Packer) error
	Unmarshal([]byte, interface{}) error
}

Codec marshals and unmarshals

func New

func New(tagName string, maxSliceLen int) Codec

New returns a new, concurrency-safe codec

func NewDefault

func NewDefault() Codec

NewDefault returns a new codec with reasonable default values

type Manager added in v1.0.6

type Manager interface {
	// Associate the given codec with the given version ID
	RegisterCodec(version uint16, codec Codec) error

	// Define the maximum size, in bytes, of something serialized/deserialized
	// by this codec manager
	SetMaxSize(int)

	// Marshal the given value using the codec with the given version.
	// RegisterCodec must have been called with that version.
	Marshal(version uint16, source interface{}) (destination []byte, err error)

	// Unmarshal the given bytes into the given destination. [destination] must
	// be a pointer or an interface. Returns the version of the codec that
	// produces the given bytes.
	Unmarshal(source []byte, destination interface{}) (version uint16, err error)
}

Manager describes the functionality for managing codec versions.

func NewDefaultManager added in v1.0.6

func NewDefaultManager() Manager

NewDefaultManager returns a new codec manager.

func NewManager added in v1.0.6

func NewManager(maxSize int) Manager

NewManager returns a new codec manager.

type Registry added in v1.0.6

type Registry interface {
	Skip(int)
	RegisterType(interface{}) error
}

Registry registers new types that can be marshaled into

Jump to

Keyboard shortcuts

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