Documentation
¶
Overview ¶
Package codecapi is used by the codec package and by code generated by codec.GenerateFile. It should NOT be used directly.
Index ¶
- Variables
- func Fail(err error)
- func Failf(format string, args ...interface{})
- func Register(x interface{}, tc typeCodec)
- type DecodeOptions
- type Decoder
- func (d *Decoder) Decode() (_ interface{}, err error)
- func (d *Decoder) DecodeAny() interface{}
- func (d *Decoder) DecodeBool() bool
- func (d *Decoder) DecodeByte() byte
- func (d *Decoder) DecodeBytes() []byte
- func (d *Decoder) DecodeComplex() complex128
- func (d *Decoder) DecodeFloat() float64
- func (d *Decoder) DecodeInt() int64
- func (d *Decoder) DecodeString() string
- func (d *Decoder) DecodeUint() uint64
- func (d *Decoder) NextStructField() int
- func (d *Decoder) StartList() int
- func (d *Decoder) StartPtr() (bool, interface{})
- func (d *Decoder) StartStruct()
- func (d *Decoder) StoreRef(p interface{})
- func (d *Decoder) UnknownField(typeName string, num int)
- type EncodeOptions
- type Encoder
- func (e *Encoder) Encode(x interface{}) (err error)
- func (e *Encoder) EncodeAny(x interface{})
- func (e *Encoder) EncodeBool(b bool)
- func (e *Encoder) EncodeByte(b byte)
- func (e *Encoder) EncodeBytes(b []byte)
- func (e *Encoder) EncodeComplex(c complex128)
- func (e *Encoder) EncodeFloat(f float64)
- func (e *Encoder) EncodeInt(i int64)
- func (e *Encoder) EncodeNil()
- func (e *Encoder) EncodeString(s string)
- func (e *Encoder) EncodeUint(u uint64)
- func (e *Encoder) EndStruct()
- func (e *Encoder) StartList(len int)
- func (e *Encoder) StartPtr(isNil bool, p interface{}) bool
- func (e *Encoder) StartStruct()
Constants ¶
This section is empty.
Variables ¶
var BuiltinTypes []reflect.Type
Functions ¶
func Fail ¶
func Fail(err error)
Fail aborts the current encoding or decoding with the given error. It never returns.
Types ¶
type DecodeOptions ¶
type DecodeOptions struct {
FailOnUnknownField bool
}
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func NewDecoder(r io.Reader, opts DecodeOptions) *Decoder
func (*Decoder) Decode ¶
Decode decodes a value encoded with Encoder.Encode. It returns (nil, io.EOF) if there are no more values.
func (*Decoder) DecodeAny ¶
func (d *Decoder) DecodeAny() interface{}
DecodeAny decodes a value encoded by EncodeAny.
func (*Decoder) DecodeByte ¶
func (*Decoder) DecodeBytes ¶
DecodeBytes decodes a byte slice. It makes a copy of a portion of the underlying buffer.
func (*Decoder) DecodeComplex ¶
func (d *Decoder) DecodeComplex() complex128
DecodeComplex decodes a complex128.
func (*Decoder) DecodeFloat ¶
DecodeFloat decodes a float64.
func (*Decoder) DecodeString ¶
DecodeString decodes a string.
func (*Decoder) NextStructField ¶
NextStructField should be called by a struct decoder in a loop. It returns the field number of the next encoded field, or -1 if there are no more fields.
func (*Decoder) StartList ¶
StartList should be called before decoding any sequence of variable-length values. It returns -1 if the encoded list was nil. Otherwise, it returns the length of the sequence.
func (*Decoder) StartPtr ¶
StartPtr should be called before decoding a pointer. If the first return value is false, the destination should not be set. Otherwise, if the second return value is non-nil, assign it to the destination. Otherwise, proceed with decoding into the destination.
func (*Decoder) StartStruct ¶
func (d *Decoder) StartStruct()
StartStruct should be called before decoding a struct.
func (*Decoder) StoreRef ¶
func (d *Decoder) StoreRef(p interface{})
StoreRef should be called by a struct decoder immediately after it allocates a struct pointer.
func (*Decoder) UnknownField ¶
UnknownField should be called by a struct decoder when it sees a field number that it doesn't know.
type EncodeOptions ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
func NewEncoder(w io.Writer, opts EncodeOptions) *Encoder
func (*Encoder) EncodeAny ¶
func (e *Encoder) EncodeAny(x interface{})
EncodeAny encodes a Go type. The type must have been registered with Register.
func (*Encoder) EncodeByte ¶
func (*Encoder) EncodeBytes ¶
EncodeBytes encodes a byte slice.
func (*Encoder) EncodeComplex ¶
func (e *Encoder) EncodeComplex(c complex128)
EncodeComplex encodes a complex128.
func (*Encoder) EncodeFloat ¶
EncodeFloat encodes a float64.
func (*Encoder) EncodeString ¶
EncodeString encodes a string.
func (*Encoder) EndStruct ¶
func (e *Encoder) EndStruct()
EndStruct should be called after encoding a struct.
func (*Encoder) StartList ¶
StartList should be called before encoding any sequence of variable-length values.
func (*Encoder) StartPtr ¶
StartPtr should be called before encoding a pointer. The isNil argument says whether the pointer is nil. The p argument is the pointer. If StartPtr returns false, encoding should not proceed.
func (*Encoder) StartStruct ¶
func (e *Encoder) StartStruct()