Documentation ¶
Overview ¶
Package codec is the body's codec set.
Copyright 2015-2018 HenryLee. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package codec is a generated protocol buffer package.
It is generated from these files:
empty.proto
It has these top-level messages:
PbEmpty
Index ¶
- Constants
- Variables
- func Marshal(codecID byte, v interface{}) ([]byte, error)
- func MarshalByName(codecName string, 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
- func UnmarshalByName(codecName string, data []byte, v interface{}) error
- type Codec
- type FormCodec
- type JsonCodec
- type PbEmpty
- func (*PbEmpty) Descriptor() ([]byte, []int)
- func (m *PbEmpty) Marshal() (dAtA []byte, err error)
- func (m *PbEmpty) MarshalTo(dAtA []byte) (int, error)
- func (*PbEmpty) ProtoMessage()
- func (m *PbEmpty) Reset()
- func (m *PbEmpty) Size() (n int)
- func (m *PbEmpty) String() string
- func (m *PbEmpty) Unmarshal(dAtA []byte) error
- type PlainCodec
- type ProtoCodec
Constants ¶
const ( // NilCodecID empty codec id. NilCodecID byte = 0 // NilCodecName empty codec name. NilCodecName string = "" )
const ( NAME_FORM = "form" ID_FORM = 'f' )
form(url encode) codec name and id
const ( NAME_JSON = "json" ID_JSON = 'j' )
json codec name and id
const ( NAME_PLAIN = "plain" ID_PLAIN = 's' )
plain text codec name and id
const ( NAME_PROTOBUF = "protobuf" ID_PROTOBUF = 'p' )
protobuf codec name and id
Variables ¶
var ( ErrInvalidLengthEmpty = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowEmpty = fmt.Errorf("proto: integer overflow") )
var ( // EmptyStruct empty struct for protobuf EmptyStruct = new(PbEmpty) )
Functions ¶
func MarshalByName ¶
MarshalByName returns the encoding of v.
func ProtoMarshal ¶
ProtoMarshal returns the Protobuf encoding of v.
func ProtoUnmarshal ¶
ProtoUnmarshal parses the Protobuf-encoded data and stores the result in the value pointed to by v.
func Unmarshal ¶
Unmarshal parses the encoded data and stores the result in the value pointed to by v.
func UnmarshalByName ¶
UnmarshalByName parses the encoded data and stores the result in the value pointed to by v.
Types ¶
type Codec ¶
type Codec interface { // ID returns codec id. ID() byte // Name returns codec name. Name() string // Marshal returns the encoding of v. Marshal(v interface{}) ([]byte, error) // Unmarshal parses the encoded data and stores the result // in the value pointed to by v. Unmarshal(data []byte, v interface{}) error }
Codec makes the body's Encoder and Decoder
type FormCodec ¶
type FormCodec struct{}
FormCodec url encode codec
type JsonCodec ¶
type JsonCodec struct{}
JsonCodec json codec
type PbEmpty ¶
type PbEmpty struct { }
func (*PbEmpty) Descriptor ¶
func (*PbEmpty) ProtoMessage ¶
func (*PbEmpty) ProtoMessage()
type PlainCodec ¶
type PlainCodec struct{}
PlainCodec plain text codec
func (PlainCodec) Marshal ¶
func (PlainCodec) Marshal(v interface{}) ([]byte, error)
Marshal returns the string encoding of v.
func (PlainCodec) Unmarshal ¶
func (PlainCodec) Unmarshal(data []byte, v interface{}) error
Unmarshal parses the string-encoded data and stores the result in the value pointed to by v.
type ProtoCodec ¶
type ProtoCodec struct{}
ProtoCodec protobuf codec
func (ProtoCodec) Marshal ¶
func (ProtoCodec) Marshal(v interface{}) ([]byte, error)
Marshal returns the Protobuf encoding of v.
func (ProtoCodec) Unmarshal ¶
func (ProtoCodec) Unmarshal(data []byte, v interface{}) error
Unmarshal parses the Protobuf-encoded data and stores the result in the value pointed to by v.