marshal

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: GPL-3.0 Imports: 6 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

View Source
var MarshalizersAvailableForTesting = map[string]Marshalizer{
	"json":     &JsonMarshalizer{},
	"protobuf": &GogoProtoMarshalizer{},
}

MarshalizersAvailableForTesting represents all marshalizers registered that will be used in tests. In this manner we assure that any modification on a serializable DTO will always be checked against all registered marshalizers

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.

type Sizer added in v1.0.115

type Sizer interface {
	Size() (n int)
}

Sizer contains method Size that is needed to get the size of a proto obj

type TxJsonMarshalizer added in v1.0.114

type TxJsonMarshalizer struct {
}

TxJsonMarshalizer represents a custom marshalizer for transactions which does not escape HTML characters in strings

func (*TxJsonMarshalizer) IsInterfaceNil added in v1.0.114

func (t *TxJsonMarshalizer) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*TxJsonMarshalizer) Marshal added in v1.0.114

func (t *TxJsonMarshalizer) Marshal(obj interface{}) ([]byte, error)

Marshal tries to serialize the obj parameter

func (*TxJsonMarshalizer) Unmarshal added in v1.0.114

func (t *TxJsonMarshalizer) Unmarshal(obj interface{}, buff []byte) error

Unmarshal tries to deserialize input buffer values into input object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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