Documentation ¶
Index ¶
- Constants
- Variables
- func ProtoMarshal(v interface{}) ([]byte, error)
- func ProtoUnmarshal(b []byte, v interface{}) error
- func Reg(codec Codec)
- type Codec
- type Decoder
- type Encoder
- type JsonCodec
- type JsonDecoder
- type JsonEncoder
- type JsoniterCodec
- type JsoniterDecoder
- type JsoniterEncoder
- type ProtoCodec
- type ProtoDecoder
- type ProtoEncoder
- type StringCodec
- type StringDecoder
- type StringEncoder
Constants ¶
const (
NilCodecId byte = 0
)
Variables ¶
var ( ErrInvalidLengthempty = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowempty = fmt.Errorf("proto: integer overflow") )
var Empty = new(empty)
Functions ¶
func ProtoMarshal ¶
func ProtoUnmarshal ¶
Types ¶
type Codec ¶
type Codec interface { // Id returns codec id. Id() byte // Name returns codec name. Name() string // NewEncoder returns a new encoder that writes to writer. NewEncoder(writer io.Writer) Encoder // NewDecoder returns a new decoder that reads from limit reader. NewDecoder(limitReader io.Reader) Decoder }
Codec makes Encoder and Decoder
type Decoder ¶
type Decoder interface {
Decode(v interface{}) error
}
Decoder decodes data
func NewDecoderById ¶
NewDecoderById returns a new decoder that reads from limit reader.
type Encoder ¶
type Encoder interface {
Encode(v interface{}) error
}
Encoder encodes data
func NewEncoderById ¶
NewEncoderById returns a new encoder that writes to writer.
type JsonCodec ¶
type JsonCodec struct{}
JsonCodec json codec
func (*JsonCodec) NewDecoder ¶
NewDecoder returns a new json decoder that reads from limit reader.
type JsonDecoder ¶
type JsonDecoder struct {
// contains filtered or unexported fields
}
JsonDecoder json decoder
func (*JsonDecoder) Decode ¶
func (p *JsonDecoder) Decode(v interface{}) error
Decode reads the next json-encoded value from its input and stores it in the value pointed to by v.
type JsonEncoder ¶
type JsonEncoder struct {
// contains filtered or unexported fields
}
JsonEncoder json decoder
func (*JsonEncoder) Encode ¶
func (p *JsonEncoder) Encode(v interface{}) error
Encode writes the json encoding of v to the writer.
type JsoniterCodec ¶
type JsoniterCodec struct{}
JsoniterCodec json codec
func (*JsoniterCodec) NewDecoder ¶
func (*JsoniterCodec) NewDecoder(limitReader io.Reader) Decoder
NewDecoder returns a new json decoder that reads from limit reader.
func (*JsoniterCodec) NewEncoder ¶
func (*JsoniterCodec) NewEncoder(writer io.Writer) Encoder
NewEncoder returns a new json encoder that writes to writer.
type JsoniterDecoder ¶
type JsoniterDecoder struct {
// contains filtered or unexported fields
}
JsoniterDecoder json decoder
func (*JsoniterDecoder) Decode ¶
func (p *JsoniterDecoder) Decode(v interface{}) error
Decode reads the next json-encoded value from its input and stores it in the value pointed to by v.
type JsoniterEncoder ¶
type JsoniterEncoder struct {
// contains filtered or unexported fields
}
JsoniterEncoder json decoder
func (*JsoniterEncoder) Encode ¶
func (p *JsoniterEncoder) Encode(v interface{}) error
Encode writes the json encoding of v to the writer.
type ProtoCodec ¶
type ProtoCodec struct{}
ProtoCodec protobuf codec
func (*ProtoCodec) NewDecoder ¶
func (*ProtoCodec) NewDecoder(limitReader io.Reader) Decoder
NewDecoder returns a new protobuf decoder that reads from limit reader.
func (*ProtoCodec) NewEncoder ¶
func (*ProtoCodec) NewEncoder(writer io.Writer) Encoder
NewEncoder returns a new protobuf encoder that writes to writer.
type ProtoDecoder ¶
type ProtoDecoder struct {
// contains filtered or unexported fields
}
ProtoDecoder proto decoder
func (*ProtoDecoder) Decode ¶
func (p *ProtoDecoder) Decode(v interface{}) error
Decode reads the next Protobuf-encoded value from its input and stores it in the value pointed to by v.
type ProtoEncoder ¶
type ProtoEncoder struct {
// contains filtered or unexported fields
}
ProtoEncoder proto decoder
func (*ProtoEncoder) Encode ¶
func (p *ProtoEncoder) Encode(v interface{}) error
Encode writes the Protobuf encoding of v to the writer.
type StringCodec ¶
type StringCodec struct{}
StringCodec string codec
func (*StringCodec) NewDecoder ¶
func (*StringCodec) NewDecoder(limitReader io.Reader) Decoder
NewDecoder returns a new string decoder that reads from limit reader.
func (*StringCodec) NewEncoder ¶
func (*StringCodec) NewEncoder(writer io.Writer) Encoder
NewEncoder returns a new string encoder that writes to writer.
type StringDecoder ¶
type StringDecoder struct {
// contains filtered or unexported fields
}
StringDecoder string decoder
func (*StringDecoder) Decode ¶
func (p *StringDecoder) Decode(v interface{}) error
Decode reads the next string-encoded value from its input and stores it in the value pointed to by v.
type StringEncoder ¶
type StringEncoder struct {
// contains filtered or unexported fields
}
StringEncoder string decoder
func (*StringEncoder) Encode ¶
func (p *StringEncoder) Encode(v interface{}) error
Encode writes the string encoding of v to the writer.