Documentation ¶
Index ¶
- Variables
- func ImportCodeC(t reflect.Type, codec Codec)
- func Marshal(v interface{}) (output []byte, err error)
- func Unmarshal(b []byte, v interface{}) (err error)
- type Codec
- type Decoder
- func (d *Decoder) Decode(v interface{}) (err error)
- func (d *Decoder) Read(b []byte) (int, error)
- func (d *Decoder) ReadBool() (bool, error)
- func (d *Decoder) ReadFloat32() (out float32, err error)
- func (d *Decoder) ReadFloat64() (out float64, err error)
- func (d *Decoder) ReadUint16() (out uint16, err error)
- func (d *Decoder) ReadUint32() (out uint32, err error)
- func (d *Decoder) ReadUint64() (out uint64, err error)
- func (d *Decoder) ReadUvarint() (uint64, error)
- func (d *Decoder) ReadVarint() (int64, error)
- func (d *Decoder) Slice(n int) ([]byte, error)
- type Encoder
- func (e *Encoder) Encode(v interface{}) (err error)
- func (e *Encoder) Write(p []byte)
- func (e *Encoder) WriteFloat32(v float32)
- func (e *Encoder) WriteFloat64(v float64)
- func (e *Encoder) WriteUint16(v uint16)
- func (e *Encoder) WriteUint32(v uint32)
- func (e *Encoder) WriteUint64(v uint64)
- func (e *Encoder) WriteUvarint(x uint64)
- func (e *Encoder) WriteVarint(v int64)
- type Reader
Constants ¶
This section is empty.
Variables ¶
var ( LittleEndian = binary.LittleEndian BigEndian = binary.BigEndian )
Constants
var (
MAXSLICESIZE = ^uint(0) >> 1
)
Functions ¶
func ImportCodeC ¶
Types ¶
type Codec ¶
type Codec interface { EncodeTo(*Encoder, reflect.Value) error DecodeTo(*Decoder, reflect.Value) error }
Codec represents a single part Codec, which can encode and decode something.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder represents a binary decoder.
func (*Decoder) ReadFloat32 ¶
ReadFloat32 reads a float32
func (*Decoder) ReadFloat64 ¶
ReadFloat64 reads a float64
func (*Decoder) ReadUint16 ¶
ReadUint16 reads a uint16
func (*Decoder) ReadUint32 ¶
ReadUint32 reads a uint32
func (*Decoder) ReadUint64 ¶
ReadUint64 reads a uint64
func (*Decoder) ReadUvarint ¶
ReadUvarint reads a variable-length Uint64 from the buffer.
func (*Decoder) ReadVarint ¶
ReadVarint reads a variable-length Int64 from the buffer.
func (*Decoder) Slice ¶
Slice selects a sub-slice of next bytes. This is similar to Read() but does not actually perform a copy, but simply uses the underlying slice (if available) and returns a sub-slice pointing to the same array. Since this requires access to the underlying data, this is only available for our default reader.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder represents a binary encoder.
func (*Encoder) WriteFloat32 ¶
WriteFloat32 a 32-bit floating point number
func (*Encoder) WriteFloat64 ¶
WriteFloat64 a 64-bit floating point number
func (*Encoder) WriteUvarint ¶
WriteUvarint writes a variable size unsigned integer
func (*Encoder) WriteVarint ¶
WriteVarint writes a variable size integer