marshal

package
v0.0.0-...-7365f8e Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT 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 any) ([]byte, error)

	// Unmarshal is used to deserialize []byte to any
	Unmarshal(data []byte, v any) 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 any) ([]byte, error)

func (*MsgPacker) Unmarshal

func (s *MsgPacker) Unmarshal(d []byte, v any) 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 any) ([]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) (any, 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