codec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

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.

func TestMessagesEncoding added in v0.0.27

func TestMessagesEncoding(t *testing.T, codecs []Codec, messages ...interface{})

TestMessagesEncoding tests the input messages if the values encoding persists the same.

Types

type Codec

type Codec interface {
	Marshal(interface{}) ([]byte, error)
	Unmarshal([]byte, interface{}) error
	Encoding() string
	Name() 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.

Directories

Path Synopsis
internal
pb

Jump to

Keyboard shortcuts

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