Documentation
¶
Index ¶
- Constants
- Variables
- func Marshal(codecID byte, v interface{}) ([]byte, error)
- func ProtoMarshal(v interface{}) ([]byte, error)
- func ProtoUnmarshal(data []byte, v interface{}) error
- func Reg(codec Codec)
- func Unmarshal(codecID byte, data []byte, v interface{}) error
- type Codec
- type FormCodec
- type JSONCodec
- type PbEmpty
- type PlainCodec
- type ProtoCodec
- type XMLCodec
Constants ¶
View Source
const ( // NilCodecID 空的编解码器id. NilCodecID byte = 0 // NilCodecName 空的编解码器名称. NilCodecName string = "" )
View Source
const ( NameForm = "form" IdForm = 'f' )
View Source
const ( NameJson = "json" IdJson = 'j' )
View Source
const ( NamePlain = "plain" IdPlain = 's' )
View Source
const ( NameProtobuf = "protobuf" IdProtobuf = 'p' )
View Source
const ( NameXml = "xml" IdXml = 'x' )
Variables ¶
View Source
var File_empty_proto protoreflect.FileDescriptor
View Source
var ( // PbEmptyStruct 如果需要编码nil 或者struct,则不能编码,使用空的 PbEmptyStruct = new(PbEmpty) )
Functions ¶
func ProtoMarshal ¶ added in v0.2.0
func ProtoUnmarshal ¶ added in v0.2.0
Types ¶
type Codec ¶
type Codec interface { ID() byte Name() string Marshal(interface{}) ([]byte, error) Unmarshal([]byte, interface{}) error }
Codec 消息内容的编解码器
type PbEmpty ¶ added in v0.2.0
type PbEmpty struct {
// contains filtered or unexported fields
}
func (*PbEmpty) Descriptor
deprecated
added in
v0.2.0
func (*PbEmpty) ProtoMessage ¶ added in v0.2.0
func (*PbEmpty) ProtoMessage()
func (*PbEmpty) ProtoReflect ¶ added in v0.2.0
func (x *PbEmpty) ProtoReflect() protoreflect.Message
type PlainCodec ¶ added in v0.0.3
type PlainCodec struct{}
PlainCodec plain text codec
func (PlainCodec) Marshal ¶ added in v0.0.3
func (PlainCodec) Marshal(v interface{}) ([]byte, error)
func (PlainCodec) Unmarshal ¶ added in v0.0.3
func (PlainCodec) Unmarshal(data []byte, v interface{}) error
type ProtoCodec ¶ added in v0.2.0
type ProtoCodec struct{}
func (ProtoCodec) ID ¶ added in v0.2.0
func (ProtoCodec) ID() byte
func (ProtoCodec) Marshal ¶ added in v0.2.0
func (ProtoCodec) Marshal(v interface{}) ([]byte, error)
Marshal 编码
func (ProtoCodec) Name ¶ added in v0.2.0
func (ProtoCodec) Name() string
func (ProtoCodec) Unmarshal ¶ added in v0.2.0
func (ProtoCodec) Unmarshal(data []byte, v interface{}) error
Unmarshal 解码
Source Files
¶
Click to show internal directories.
Click to hide internal directories.