serialize

package
v2.10.18 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongValueType = errors.New("protobuf: convert on wrong type value")

ErrWrongValueType is the error used for marshal the value with protobuf encoding.

Functions

This section is empty.

Types

type JsonSerializer

type JsonSerializer struct{}

JsonSerializer implements the serialize.Serializer interface

func NewJsonSerializer

func NewJsonSerializer() *JsonSerializer

NewJsonSerializer returns a new Serializer.

func (*JsonSerializer) Marshal

func (s *JsonSerializer) Marshal(v any) ([]byte, error)

Marshal returns the JSON encoding of v.

func (*JsonSerializer) Unmarshal

func (s *JsonSerializer) Unmarshal(data []byte, v any) error

Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v.

type Marshaler

type Marshaler interface {
	Marshal(any) ([]byte, error)
}

Marshaler represents a marshal interface

type ProtoSerializer

type ProtoSerializer struct{}

ProtoSerializer implements the serialize.Serializer interface

func NewProtoSerializer

func NewProtoSerializer() *ProtoSerializer

NewProtoSerializer returns a new Serializer.

func (*ProtoSerializer) Marshal

func (s *ProtoSerializer) Marshal(v any) ([]byte, error)

Marshal returns the protobuf encoding of v.

func (*ProtoSerializer) Unmarshal

func (s *ProtoSerializer) Unmarshal(data []byte, v any) error

Unmarshal parses the protobuf-encoded data and stores the result in the value pointed to by v.

type Serializer

type Serializer interface {
	Marshaler
	Unmarshaler
}

Serializer is the interface that groups the basic Marshal and Unmarshal methods.

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte, any) error
}

Unmarshaler represents a Unmarshal interface

Jump to

Keyboard shortcuts

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