Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Codecs = map[CodecType]Codec{ CodeTypeNone: NewRawCoder(), CodeTypeBinary: NewBinaryCoder(), CodeTypeGob: NewGobCoder(), CodeTypeJce: NewJceCoder(), CodeTypeJson: NewJsonCoder(), CodeTypePb: NewPbCoder(), CodeTypeThrift: NewThriftCoder(), CodeTypeMsgpack: NewMsgpackCoder(), }
Functions ¶
func UnRegisterCodec ¶
Types ¶
type BinaryCoder ¶
type BinaryCoder struct {
// contains filtered or unexported fields
}
二进制协议
func NewBinaryCoder ¶
func NewBinaryCoder() *BinaryCoder
func (*BinaryCoder) String ¶
func (b *BinaryCoder) String() string
func (*BinaryCoder) UnmarshalFrom ¶
func (b *BinaryCoder) UnmarshalFrom(r io.Reader, v any) error
type Codec ¶
type Codec interface { Marshal(v any) ([]byte, error) MarshalTo(v any, w io.Writer) error Unmarshal(data []byte, v any) error UnmarshalFrom(r io.Reader, v any) error String() string }
codec 接口
type CodecType ¶
type CodecType string
const ( CodeTypeNone CodecType = "code/none" CodeTypeBinary CodecType = "code/binary" CodeTypeGob CodecType = "code/gob" CodeTypeJce CodecType = "code/jce" CodeTypeJson CodecType = "code/json" CodeTypePb CodecType = "code/pb" CodeTypeThrift CodecType = "code/thrift" CodeTypeMsgpack CodecType = "code/msgpack" )
type JsonCoder ¶
type JsonCoder struct { }
json 协议
func NewJsonCoder ¶
func NewJsonCoder() *JsonCoder
type MsgpackCoder ¶
type MsgpackCoder struct { }
msgpack 协议
func NewMsgpackCoder ¶
func NewMsgpackCoder() *MsgpackCoder
func (*MsgpackCoder) String ¶
func (m *MsgpackCoder) String() string
func (*MsgpackCoder) UnmarshalFrom ¶
func (m *MsgpackCoder) UnmarshalFrom(r io.Reader, v any) (err error)
type RawCoder ¶
type RawCoder struct {
// contains filtered or unexported fields
}
裸编码,即默认不编码,只支持原生为 []byte 类型
func NewRawCoder ¶
func NewRawCoder() *RawCoder
type ThriftCoder ¶
type ThriftCoder struct { }
thrift 协议
func NewThriftCoder ¶
func NewThriftCoder() *ThriftCoder
func (*ThriftCoder) String ¶
func (Thrift *ThriftCoder) String() string
func (*ThriftCoder) UnmarshalFrom ¶
func (t *ThriftCoder) UnmarshalFrom(r io.Reader, v any) (err error)
Click to show internal directories.
Click to hide internal directories.