Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrInvalidMessage = errors.New("message type is invalid")
)
Functions ¶
Types ¶
type Codec ¶
type Codec interface {
// Encode 将对象序列化为字节数组
Encode(v interface{}) ([]byte, error)
// Decode 将字节数组反序列化为对象
Decode(data []byte, v interface{}) error
// Name 返回编解码器的名称
Name() string
}
Codec 定义了序列化和反序列化的接口
type JsonCodec ¶
type JsonCodec struct{}
JsonCodec 实现了 Codec 接口
type ProtobufCodec ¶
type ProtobufCodec struct{}
ProtobufCodec 实现了 Codec 接口
func (*ProtobufCodec) Decode ¶
func (c *ProtobufCodec) Decode(data []byte, v interface{}) error
Decode 将 Protobuf 字节数组反序列化为对象
func (*ProtobufCodec) Encode ¶
func (c *ProtobufCodec) Encode(v interface{}) ([]byte, error)
Encode 将对象序列化为 Protobuf 字节数组
Click to show internal directories.
Click to hide internal directories.