marshal

package
v0.0.0-...-2061cc3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownType = errors.New("unknown type")

Functions

This section is empty.

Types

type Data

type Data struct {
	Type    string
	Payload []byte
	IsPtr   bool
}

type Marshaler

type Marshaler interface {
	// Marshal is used to serialize and data to a []byte
	Marshal(data interface{}) ([]byte, error)

	// Unmarshal is used to deserialize []byte to interface{}
	Unmarshal(data []byte, v interface{}) error
}

Marshaler interface is to provide serialize and deserialize methods for BRaft Node

func NewMsgPacker

func NewMsgPacker() Marshaler

type MsgPacker

type MsgPacker struct{}

func (*MsgPacker) Marshal

func (s *MsgPacker) Marshal(d interface{}) ([]byte, error)

func (*MsgPacker) Unmarshal

func (s *MsgPacker) Unmarshal(d []byte, v interface{}) error

type TypeRegister

type TypeRegister struct {
	Marshaler
	TypeMap map[string]reflect.Type
	// contains filtered or unexported fields
}

func NewTypeRegister

func NewTypeRegister(m Marshaler) *TypeRegister

func (*TypeRegister) Marshal

func (t *TypeRegister) Marshal(data interface{}) ([]byte, error)

func (*TypeRegister) RegisterType

func (t *TypeRegister) RegisterType(typ reflect.Type) (typName string, isPtr bool)

func (*TypeRegister) Unmarshal

func (t *TypeRegister) Unmarshal(data []byte) (interface{}, error)

type TypeRegisterMarshalerAdapter

type TypeRegisterMarshalerAdapter interface {
	Marshal(*TypeRegister) ([]byte, error)
}

type TypeRegisterUnmarshalerAdapter

type TypeRegisterUnmarshalerAdapter interface {
	Unmarshal(*TypeRegister, []byte) error
}

Jump to

Keyboard shortcuts

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