codec

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasRegister

func HasRegister(name PACK) bool

func Register

func Register(name PACK, adapter Instance)

Types

type Codec

type Codec interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

func NewMCPack

func NewMCPack() Codec

func NewMSGPack added in v1.1.0

func NewMSGPack() Codec

func PluginInstance

func PluginInstance(name PACK) (adapter Codec)

type Instance

type Instance func() Codec

type MCPack

type MCPack struct{}

func (*MCPack) Marshal

func (mc *MCPack) Marshal(v interface{}) ([]byte, error)

func (*MCPack) Unmarshal

func (mc *MCPack) Unmarshal(data []byte, v interface{}) error

type MSGPack added in v1.1.0

type MSGPack struct{}

func (*MSGPack) Marshal added in v1.1.0

func (mc *MSGPack) Marshal(v interface{}) ([]byte, error)

func (*MSGPack) Unmarshal added in v1.1.0

func (mc *MSGPack) Unmarshal(data []byte, v interface{}) error

type PACK

type PACK string
const (
	MCPACK  PACK = "mcpack"  // mcpack 算法: like Json decode/encode
	MSGPACK PACK = "msgpack" // msgpack https://msgpack.uptrace.dev/
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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