You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
490 B
Go
27 lines
490 B
Go
package codec
|
|
|
|
// Codec 编解码器接口
|
|
type Codec interface {
|
|
// Encode 编码
|
|
Encode(v interface{}) ([]byte, error)
|
|
|
|
// Decode 解码
|
|
Decode(data []byte, v interface{}) error
|
|
|
|
// Name 获取编解码器名称
|
|
Name() string
|
|
}
|
|
|
|
// Registry 编解码器注册表
|
|
type Registry interface {
|
|
// Register 注册编解码器
|
|
Register(name string, codec Codec) error
|
|
|
|
// Get 获取编解码器
|
|
Get(name string) (Codec, error)
|
|
|
|
// Default 获取默认编解码器
|
|
Default() Codec
|
|
}
|
|
|