serializer

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONSerializer

type JSONSerializer struct{}

JSONSerializer JSON序列化器

func (*JSONSerializer) ContentType

func (s *JSONSerializer) ContentType() string

func (*JSONSerializer) Deserialize

func (s *JSONSerializer) Deserialize(data []byte, msg *message.Message) error

func (*JSONSerializer) Serialize

func (s *JSONSerializer) Serialize(msg *message.Message) ([]byte, error)

type MsgPackSerializer

type MsgPackSerializer struct{}

MsgPackSerializer MessagePack序列化器(更高效)

func (*MsgPackSerializer) ContentType

func (s *MsgPackSerializer) ContentType() string

func (*MsgPackSerializer) Deserialize

func (s *MsgPackSerializer) Deserialize(data []byte, msg *message.Message) error

func (*MsgPackSerializer) Serialize

func (s *MsgPackSerializer) Serialize(msg *message.Message) ([]byte, error)

type Serializer

type Serializer interface {
	Serialize(msg *message.Message) ([]byte, error)
	Deserialize(data []byte, msg *message.Message) error
	ContentType() string
}

Serializer 序列化器接口

func NewSerializer

func NewSerializer(serializerType Type) (Serializer, error)

NewSerializer 创建序列化器

type Type

type Type string

Type 序列化器类型

const (
	Json    Type = "json"
	MsgPack Type = "msgpack"
)

Jump to

Keyboard shortcuts

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