serialize

package
v0.0.0-...-1609ee8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBinaryEventOverflow = errors.New("Binary event data overflow")
)

Parse errors

Functions

func NumberFromBytesBigEndian

func NumberFromBytesBigEndian(buf []byte) uint64

NumberFromBytesBigEndian parses the buf by big endian order

func NumberFromBytesLittleEndian

func NumberFromBytesLittleEndian(buf []byte) uint64

NumberFromBytesLittleEndian parses the buf by little endian order

Types

type BinReader

type BinReader struct {
	// contains filtered or unexported fields
}

BinReader reads values from the binary data

func NewBinReader

func NewBinReader(data []byte) *BinReader

NewBinReader creates a new reader

func (*BinReader) Empty

func (r *BinReader) Empty() bool

Empty returns true if unread buffer is empty

func (*BinReader) End

func (r *BinReader) End()

End release the internal buffer

func (*BinReader) LeftBytes

func (r *BinReader) LeftBytes() []byte

LeftBytes reads the left bytes in the buffer

func (*BinReader) ReadBytes

func (r *BinReader) ReadBytes(sz int) ([]byte, error)

ReadBytes reads bytes with given size

func (*BinReader) ReadBytesUntilTerm

func (r *BinReader) ReadBytesUntilTerm() ([]byte, error)

ReadBytesUntilTerm read the buffer bytes until meet terminate byte(0)

func (*BinReader) ReadEOFString

func (r *BinReader) ReadEOFString() (string, error)

ReadEOFString reads string with eof from the buffer

func (*BinReader) ReadInt16

func (r *BinReader) ReadInt16() (int16, error)

ReadInt16 reads int16 from the buffer

func (*BinReader) ReadInt24

func (r *BinReader) ReadInt24() (int32, error)

ReadInt24 reads the next 3 bytes as the int32 number

func (*BinReader) ReadInt32

func (r *BinReader) ReadInt32() (int32, error)

ReadInt32 reads int32 from the buffer

func (*BinReader) ReadInt64

func (r *BinReader) ReadInt64() (int64, error)

ReadInt64 reads int64 from the buffer

func (*BinReader) ReadInt8

func (r *BinReader) ReadInt8() (int8, error)

ReadInt8 reads int8 from the buffer

func (*BinReader) ReadLenString

func (r *BinReader) ReadLenString() (string, error)

ReadLenString reads length string from the buffer

func (*BinReader) ReadLenencBytes

func (r *BinReader) ReadLenencBytes() ([]byte, error)

ReadLenencBytes reads the lenenc bytes from the buffer

func (*BinReader) ReadLenencInt

func (r *BinReader) ReadLenencInt() (uint64, error)

ReadLenencInt reads the lenenc int from the buffer

func (*BinReader) ReadLenencString

func (r *BinReader) ReadLenencString() (string, error)

ReadLenencString reads the lenenc string from the buffer

func (*BinReader) ReadStringUntilTerm

func (r *BinReader) ReadStringUntilTerm() (string, error)

ReadStringUntilTerm read the buffer bytes until meet terminate byte(0)

func (*BinReader) ReadStringWithLen

func (r *BinReader) ReadStringWithLen(l int) (string, error)

ReadStringWithLen reads string with given length

func (*BinReader) ReadUint16

func (r *BinReader) ReadUint16() (uint16, error)

ReadUint16 reads uint16 from the buffer

func (*BinReader) ReadUint24

func (r *BinReader) ReadUint24() (uint32, error)

ReadUint24 reads the next 3 bytes as the uint32 number

func (*BinReader) ReadUint32

func (r *BinReader) ReadUint32() (uint32, error)

ReadUint32 reads uint32 from the buffer

func (*BinReader) ReadUint48

func (r *BinReader) ReadUint48() (uint64, error)

ReadUint48 reads uint48 from the buffer

func (*BinReader) ReadUint64

func (r *BinReader) ReadUint64() (uint64, error)

ReadUint64 reads uint64 from the buffer

func (*BinReader) ReadUint8

func (r *BinReader) ReadUint8() (uint8, error)

ReadUint8 reads uint8 from the buffer

type BinWriter

type BinWriter struct {
	// contains filtered or unexported fields
}

BinWriter writes value to binary buffer

func NewBinWriter

func NewBinWriter(b []byte) *BinWriter

NewBinWriter creates a new writer

func (*BinWriter) Bytes

func (w *BinWriter) Bytes() []byte

Bytes return the write bytes buffer

func (*BinWriter) End

func (w *BinWriter) End()

End release the internal buffer

func (*BinWriter) WriteBytes

func (w *BinWriter) WriteBytes(data []byte) error

WriteBytes write bytes to the buffer

func (*BinWriter) WriteEOFString

func (w *BinWriter) WriteEOFString(s string) error

WriteEOFString write bytes to the buffer

func (*BinWriter) WriteInt16

func (w *BinWriter) WriteInt16(v int16) error

WriteInt16 writes int16 to the buffer

func (*BinWriter) WriteInt32

func (w *BinWriter) WriteInt32(v int32) error

WriteInt32 writes int32 to the buffer

func (*BinWriter) WriteInt64

func (w *BinWriter) WriteInt64(v int64) error

WriteInt64 writes int64 to the buffer

func (*BinWriter) WriteInt8

func (w *BinWriter) WriteInt8(v int8) error

WriteInt8 writes int8 to the buffer

func (*BinWriter) WriteLenBytes

func (w *BinWriter) WriteLenBytes(data []byte) error

WriteLenBytes writes byte slice with length as prefix

func (*BinWriter) WriteLenString

func (w *BinWriter) WriteLenString(s string) error

WriteLenString writes a string with length as prefix

func (*BinWriter) WriteStringWithTerm

func (w *BinWriter) WriteStringWithTerm(s string) error

WriteStringWithTerm writes a string with '\0' terminate

func (*BinWriter) WriteUint16

func (w *BinWriter) WriteUint16(v uint16) error

WriteUint16 writes uint16 to the buffer

func (*BinWriter) WriteUint32

func (w *BinWriter) WriteUint32(v uint32) error

WriteUint32 writes uint32 to the buffer

func (*BinWriter) WriteUint64

func (w *BinWriter) WriteUint64(v uint64) error

WriteUint64 writes uint64 to the buffer

func (*BinWriter) WriteUint8

func (w *BinWriter) WriteUint8(v uint8) error

WriteUint8 writes uint8 to the buffer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL