marshal

package
v1.0.94 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMarshallingProto = errors.New("can not serialize the object")

ErrMarshallingProto is raised when the object does not implement proto.Message

View Source
var ErrUnknownMarshalizer = errors.New("unknown marshalizer")

ErrUnknownMarshalizer signals that the specified marshalizer does not have a ready to use implementation

View Source
var ErrUnmarshallingBadSize = errors.New("imput buffer too long")

ErrUnmarshallingBadSize is raised when the provided serialized data size exceeds the re-serialized data size plus an additional provided delta

View Source
var ErrUnmarshallingProto = errors.New("obj does not implement proto.Message")

ErrUnmarshallingProto is raised when the object that needs to be unmarshaled does not implement proto.Message

Functions

This section is empty.

Types

type GogoProtoMarshalizer

type GogoProtoMarshalizer struct {
}

GogoProtoMarshalizer implements marshaling with protobuf

func (*GogoProtoMarshalizer) IsInterfaceNil

func (x *GogoProtoMarshalizer) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*GogoProtoMarshalizer) Marshal

func (x *GogoProtoMarshalizer) Marshal(obj interface{}) ([]byte, error)

Marshal does the actual serialization of an object The object to be serialized must implement the gogoProtoObj interface

func (*GogoProtoMarshalizer) Unmarshal

func (x *GogoProtoMarshalizer) Unmarshal(obj interface{}, buff []byte) error

Unmarshal does the actual deserialization of an object The object to be deserialized must implement the gogoProtoObj interface

type GogoProtoObj

type GogoProtoObj interface {
	gproto.Marshaler
	gproto.Unmarshaler
	proto.Message
}

GogoProtoObj groups the necessary of a gogo protobuf marshalizeble object

type JsonMarshalizer

type JsonMarshalizer struct {
}

JsonMarshalizer implements Marshalizer interface using JSON format

func (*JsonMarshalizer) IsInterfaceNil

func (jm *JsonMarshalizer) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (JsonMarshalizer) Marshal

func (jm JsonMarshalizer) Marshal(obj interface{}) ([]byte, error)

Marshal tries to serialize obj parameter

func (JsonMarshalizer) Unmarshal

func (jm JsonMarshalizer) Unmarshal(obj interface{}, buff []byte) error

Unmarshal tries to deserialize input buffer values into input object

type Marshalizer

type Marshalizer interface {
	Marshal(obj interface{}) ([]byte, error)
	Unmarshal(obj interface{}, buff []byte) error
	IsInterfaceNil() bool
}

Marshalizer defines the 2 basic operations: serialize (marshal) and deserialize (unmarshal)

func NewSizeCheckUnmarshalizer

func NewSizeCheckUnmarshalizer(m Marshalizer, maxDelta uint32) Marshalizer

NewSizeCheckUnmarshalizer creates a wrapper around an existing marshalizer m which, during unmarshaling, also checks that the provided buffer dose not contain additional unused data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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