marshal

package
v1.0.75 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 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 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{},
	"capnp":    &CapnpMarshalizer{},
	"protobuf": &ProtobufMarshalizer{},
}

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 CapnpMarshalizer added in v1.0.3

type CapnpMarshalizer struct {
}

CapnpMarshalizer implements marshaling with capnproto

func (*CapnpMarshalizer) IsInterfaceNil added in v1.0.16

func (x *CapnpMarshalizer) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*CapnpMarshalizer) Marshal added in v1.0.3

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

Marshal does the actual serialization of an object through capnproto The object to be serialized must implement the data.CapnpHelper interface

func (*CapnpMarshalizer) Unmarshal added in v1.0.3

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

Unmarshal does the actual deserialization of an object through capnproto The object to be deserialized must implement the data.CapnpHelper interface

type JsonMarshalizer

type JsonMarshalizer struct {
}

JsonMarshalizer implements Marshalizer interface using JSON format

func (*JsonMarshalizer) IsInterfaceNil

func (j *JsonMarshalizer) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (JsonMarshalizer) Marshal

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

Marshal tries to serialize obj parameter

func (JsonMarshalizer) Unmarshal

func (j 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 ProtobufMarshalizer added in v1.0.3

type ProtobufMarshalizer struct {
}

ProtobufMarshalizer implements marshaling with protobuf

func (*ProtobufMarshalizer) IsInterfaceNil added in v1.0.16

func (x *ProtobufMarshalizer) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ProtobufMarshalizer) Marshal added in v1.0.3

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

Marshal does the actual serialization of an object through capnproto The object to be serialized must implement the data.CapnpHelper interface

func (*ProtobufMarshalizer) Unmarshal added in v1.0.3

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

Unmarshal does the actual deserialization of an object through capnproto The object to be deserialized must implement the data.CapnpHelper interface

Jump to

Keyboard shortcuts

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