codec

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodingGOB

func EncodingGOB() string

EncodingGOB returns json encoding.

func EncodingJSON

func EncodingJSON() string

EncodingJSON returns json encoding.

func EncodingProto

func EncodingProto() string

EncodingProto returns json encoding.

func Register

func Register(codec Codec) error

Register registers the codec in the mapping.

Types

type Codec

type Codec interface {
	Marshal(interface{}) ([]byte, error)
	Unmarshal([]byte, interface{}) error
	Encoding() string
}

Codec is an interface for all codecs to implement the

func GOB

func GOB() Codec

GOB gets std gob codec.

func Get

func Get(encoding string) (Codec, bool)

Get returns a codec for provided encoding name.

func JSON

func JSON() Codec

JSON gets std json codec implementation.

func Proto

func Proto() Codec

Proto gets std protobuf codec.

type ProtoMarshaler

type ProtoMarshaler interface {
	MarshalProto() ([]byte, error)
}

ProtoMarshaler is an interface used by the protobuf codec used to custom marshal proto message.

type ProtoUnmarshaler

type ProtoUnmarshaler interface {
	UnmarshalProto([]byte) error
}

ProtoUnmarshaler is an interface used for custom unmarshalling proto message.

Jump to

Keyboard shortcuts

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