Documentation
¶
Index ¶
- func AddUint16Perfix(bytes []byte) []byte
- func AddUint32Perfix(bytes []byte) []byte
- func AddUint64Perfix(bytes []byte) []byte
- type Packer
- func (p *Packer) Error() error
- func (p *Packer) PushByte(b byte) *Packer
- func (p *Packer) PushBytes(bytes []byte) *Packer
- func (p *Packer) PushFloat32(i float32) *Packer
- func (p *Packer) PushFloat64(i float64) *Packer
- func (p *Packer) PushInt16(i int16) *Packer
- func (p *Packer) PushInt32(i int32) *Packer
- func (p *Packer) PushInt64(i int64) *Packer
- func (p *Packer) PushString(s string) *Packer
- func (p *Packer) PushUint16(i uint16) *Packer
- func (p *Packer) PushUint32(i uint32) *Packer
- func (p *Packer) PushUint64(i uint64) *Packer
- func (p *Packer) PushUint8(i uint8) *Packer
- func (p *Packer) PushVarString(s string) *Packer
- type Unpacker
- func (u *Unpacker) BytesWithUint16Perfix(bytes *[]byte) *Unpacker
- func (u *Unpacker) BytesWithUint16Prefix(bytes *[]byte) *Unpacker
- func (u *Unpacker) BytesWithUint32Perfix(bytes *[]byte) *Unpacker
- func (u *Unpacker) BytesWithUint32Prefix(bytes *[]byte) *Unpacker
- func (u *Unpacker) BytesWithUint64Perfix(bytes *[]byte) *Unpacker
- func (u *Unpacker) BytesWithUint64Prefix(bytes *[]byte) *Unpacker
- func (u *Unpacker) Error() error
- func (u *Unpacker) FetchBool(b *bool) *Unpacker
- func (u *Unpacker) FetchByte(b *byte) *Unpacker
- func (u *Unpacker) FetchBytes(n uint64, bytes *[]byte) *Unpacker
- func (u *Unpacker) FetchFloat32(i *float32) *Unpacker
- func (u *Unpacker) FetchFloat64(i *float64) *Unpacker
- func (u *Unpacker) FetchInt16(i *int16) *Unpacker
- func (u *Unpacker) FetchInt32(i *int32) *Unpacker
- func (u *Unpacker) FetchInt64(i *int64) *Unpacker
- func (u *Unpacker) FetchIntDoublePair(d *map[int32]float64) *Unpacker
- func (u *Unpacker) FetchString(n uint64, s *string) *Unpacker
- func (u *Unpacker) FetchUint16(i *uint16) *Unpacker
- func (u *Unpacker) FetchUint32(i *uint32) *Unpacker
- func (u *Unpacker) FetchUint64(i *uint64) *Unpacker
- func (u *Unpacker) FetchUint8(i *uint8) *Unpacker
- func (u *Unpacker) FetchVarString(s *string) *Unpacker
- func (u *Unpacker) ShiftByte() (byte, error)
- func (u *Unpacker) ShiftBytes(_n uint64) ([]byte, error)
- func (u *Unpacker) ShiftFloat32() (float32, error)
- func (u *Unpacker) ShiftFloat64() (float64, error)
- func (u *Unpacker) ShiftInt16() (int16, error)
- func (u *Unpacker) ShiftInt32() (int32, error)
- func (u *Unpacker) ShiftInt64() (int64, error)
- func (u *Unpacker) ShiftString(n uint64) (string, error)
- func (u *Unpacker) ShiftUint16() (uint16, error)
- func (u *Unpacker) ShiftUint32() (uint32, error)
- func (u *Unpacker) ShiftUint64() (uint64, error)
- func (u *Unpacker) ShiftUint8() (uint8, error)
- func (u *Unpacker) StringWithUint16Perfix(s *string) *Unpacker
- func (u *Unpacker) StringWithUint16Prefix(s *string) *Unpacker
- func (u *Unpacker) StringWithUint32Perfix(s *string) *Unpacker
- func (u *Unpacker) StringWithUint32Prefix(s *string) *Unpacker
- func (u *Unpacker) StringWithUint64Perfix(s *string) *Unpacker
- func (u *Unpacker) StringWithUint64Prefix(s *string) *Unpacker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUint16Perfix ¶
AddUint16Perfix add 2 bytes as uint16 prefixes for bytes.
func AddUint32Perfix ¶
AddUint32Perfix add 4 bytes as uint32 prefixes for bytes.
func AddUint64Perfix ¶
AddUint64Perfix add 8 bytes as uint64 prefixes for bytes.
Types ¶
type Packer ¶
type Packer struct {
// contains filtered or unexported fields
}
Packer is a binary packer helps you pack data into an io.Writer.
func NewPacker ¶
NewPacker returns a *Packer hold an io.Writer. User must provide the byte order explicitly.
func (*Packer) PushFloat32 ¶
PushFloat32 write a float32 into writer.
func (*Packer) PushFloat64 ¶
PushFloat64 write a float64 into writer.
func (*Packer) PushString ¶
PushString write a string into writer.
func (*Packer) PushUint16 ¶
PushUint16 write a uint16 into writer.
func (*Packer) PushUint32 ¶
PushUint32 write a uint32 into writer.
func (*Packer) PushUint64 ¶
PushUint64 write a uint64 into writer.
func (*Packer) PushVarString ¶ added in v1.1.0
type Unpacker ¶
type Unpacker struct {
// contains filtered or unexported fields
}
Unpacker helps you unpack binary data from an io.Reader.
func NewUnpacker ¶
NewUnpacker returns a *Unpacker which hold an io.Reader. User must provide the byte order explicitly.
func (*Unpacker) BytesWithUint16Perfix ¶
func (*Unpacker) BytesWithUint16Prefix ¶
BytesWithUint16Prefix read 2 bytes as bytes length, then read N bytes and set it to bytes.
func (*Unpacker) BytesWithUint32Perfix ¶
func (*Unpacker) BytesWithUint32Prefix ¶
BytesWithUint32Prefix read 4 bytes as bytes length, then read N bytes and set it to bytes.
func (*Unpacker) BytesWithUint64Perfix ¶
func (*Unpacker) BytesWithUint64Prefix ¶
BytesWithUint64Prefix read 8 bytes as bytes length, then read N bytes and set it to bytes.
func (*Unpacker) FetchBytes ¶
FetchBytes read n bytes and set to bytes.
func (*Unpacker) FetchFloat32 ¶
FetchFloat32 read 4 bytes, convert it to float32 and set it to i.
func (*Unpacker) FetchFloat64 ¶
FetchFloat64 read 8 bytes, convert it to float64 and set it to i.
func (*Unpacker) FetchInt16 ¶
FetchInt16 read 2 bytes, convert it to int16 and set it to i.
func (*Unpacker) FetchInt32 ¶
FetchInt32 read 4 bytes, convert it to int32 and set it to i.
func (*Unpacker) FetchInt64 ¶
FetchInt64 read 8 bytes, convert it to int64 and set it to i.
func (*Unpacker) FetchIntDoublePair ¶ added in v1.1.0
self use, fetch an Integer - Double pair implement
func (*Unpacker) FetchString ¶
FetchString read n bytes, convert it to string and set t to s.
func (*Unpacker) FetchUint16 ¶
FetchUint16 read 2 bytes, convert it to uint16 and set it to i.
func (*Unpacker) FetchUint32 ¶
FetchUint32 read 4 bytes, convert it to uint32 and set it to i.
func (*Unpacker) FetchUint64 ¶
FetchUint64 read 8 bytes, convert it to uint64 and set it to i.
func (*Unpacker) FetchUint8 ¶
FetchUint8 read 1 byte, convert it to uint8 and set it to i.
func (*Unpacker) FetchVarString ¶ added in v1.1.0
self use, fetch a variable string implement function SerializationReader.ReadString() in C#
func (*Unpacker) ShiftByte ¶
ShiftByte fetch the first byte in io.Reader. Returns a byte and an error if exists.
func (*Unpacker) ShiftBytes ¶
ShiftBytes fetch n bytes in io.Reader. Returns a byte array and an error if exists.
func (*Unpacker) ShiftFloat32 ¶
ShiftFloat32 fetch 4 bytes in io.Reader and convert it to float32.
func (*Unpacker) ShiftFloat64 ¶
ShiftFloat64 fetch 8 bytes in io.Reader and convert it to float64.
func (*Unpacker) ShiftInt16 ¶
ShiftInt16 fetch 2 bytes in io.Reader and convert it to int16.
func (*Unpacker) ShiftInt32 ¶
ShiftInt32 fetch 4 bytes in io.Reader and convert it to int32.
func (*Unpacker) ShiftInt64 ¶
ShiftInt64 fetch 8 bytes in io.Reader and convert it to int64.
func (*Unpacker) ShiftString ¶
ShiftString fetch n bytes, convert it to string. Returns string and an error.
func (*Unpacker) ShiftUint16 ¶
ShiftUint16 fetch 2 bytes in io.Reader and convert it to uint16.
func (*Unpacker) ShiftUint32 ¶
ShiftUint32 fetch 4 bytes in io.Reader and convert it to uint32.
func (*Unpacker) ShiftUint64 ¶
ShiftUint64 fetch 8 bytes in io.Reader and convert it to uint64.
func (*Unpacker) ShiftUint8 ¶
ShiftUint8 fetch 1 byte in io.Reader and covert it to uint8
func (*Unpacker) StringWithUint16Perfix ¶
func (*Unpacker) StringWithUint16Prefix ¶
StringWithUint16Prefix read 2 bytes as string length, then read N bytes, convert it to string and set it to s.
func (*Unpacker) StringWithUint32Perfix ¶
func (*Unpacker) StringWithUint32Prefix ¶
StringWithUint32Prefix read 4 bytes as string length, then read N bytes, convert it to string and set it to s.
func (*Unpacker) StringWithUint64Perfix ¶
func (*Unpacker) StringWithUint64Prefix ¶
StringWithUint64Prefix read 8 bytes as string length, then read N bytes, convert it to string and set it to s.