Documentation ¶
Index ¶
- type Binary
- func (b *Binary) Bytes() ([]byte, error)
- func (b *Binary) Empty() bool
- func (b *Binary) Error() error
- func (b *Binary) Len() int
- func (b *Binary) PutByte(v byte)
- func (b *Binary) PutBytes(v []byte)
- func (b *Binary) PutInt32(v int32)
- func (b *Binary) PutInt64(v int64)
- func (b *Binary) PutLenBytes(data []byte)
- func (b *Binary) PutUint32(v uint32)
- func (b *Binary) PutUint64(v uint64)
- func (b *Binary) PutUvarint32(v uint32)
- func (b *Binary) PutUvarint64(v uint64)
- func (b *Binary) PutVarint32(v int32)
- func (b *Binary) PutVarint64(v int64)
- func (b *Binary) ReadBytes(n int) []byte
- func (b *Binary) ReadInt32() int32
- func (b *Binary) ReadInt64() int64
- func (b *Binary) ReadUint32() uint32
- func (b *Binary) ReadUint64() uint64
- func (b *Binary) ReadUvarint32() uint32
- func (b *Binary) ReadUvarint64() uint64
- func (b *Binary) ReadVarint32() int32
- func (b *Binary) ReadVarint64() int64
- type ByteBufReader
- func (r *ByteBufReader) GetPosition() int
- func (r *ByteBufReader) IsEnd() bool
- func (r *ByteBufReader) NewPosition(newPos int)
- func (r *ByteBufReader) ReadByte() byte
- func (r *ByteBufReader) ReadBytes(length int) []byte
- func (r *ByteBufReader) ReadLenBytes() (length int, key []byte)
- func (r *ByteBufReader) ReadUint32() uint32
- func (r *ByteBufReader) ReadUvarint64() uint64
- func (r *ByteBufReader) SubArray(start int) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binary ¶
type Binary struct {
// contains filtered or unexported fields
}
Binary is stream for writing data into memory buffer
func BinaryBufWriter ¶
BinaryBufWriter creates a binary stream for writing with provided buffer(writing start from offset 0). The caller is responsible to make sure the wrote bytes do not exceed the buffer size, otherwise the exceeding data will be missing.
func BinaryReader ¶
BinaryReader create binary stream for reading data
func (*Binary) PutLenBytes ¶
PutLenBytes encodes data as length(Uvarint64) + data
func (*Binary) PutUvarint32 ¶
PutUvarint32 encodes a uint32 into buf
func (*Binary) PutUvarint64 ¶
PutUvarint64 encodes a uint64 into buf
func (*Binary) PutVarint32 ¶
PutVarint32 encodes a int32 into buf
func (*Binary) PutVarint64 ¶
PutVarint64 encodes a int64 into buf
func (*Binary) ReadUint32 ¶
ReadUint32 read 4 bytes from buf as uint32
func (*Binary) ReadUint64 ¶
ReadUint64 read 8 bytes from buf as uint64
func (*Binary) ReadUvarint32 ¶
ReadUvarint32 reads uint32 from buffer
func (*Binary) ReadUvarint64 ¶
ReadUvarint64 reads uint64 from buffer
func (*Binary) ReadVarint32 ¶
ReadVarint32 reads int32 from buffer
func (*Binary) ReadVarint64 ¶
ReadVarint64 reads int64 from buffer
type ByteBufReader ¶
type ByteBufReader struct {
// contains filtered or unexported fields
}
TODO need refactor?? ByteBufReader provides methods to read specific values from a byte array
func NewBufReader ¶
func NewBufReader(bufArray []byte) *ByteBufReader
NewBufReader create binary stream for reading data
func (*ByteBufReader) GetPosition ¶
func (r *ByteBufReader) GetPosition() int
GetPosition indicates the current read position
func (*ByteBufReader) IsEnd ¶
func (r *ByteBufReader) IsEnd() bool
IsEnd indicates whether the end bit is read
func (*ByteBufReader) NewPosition ¶
func (r *ByteBufReader) NewPosition(newPos int)
NewPosition indicates the reset position
func (*ByteBufReader) ReadByte ¶
func (r *ByteBufReader) ReadByte() byte
ReadByte reads a byte from the buffer
func (*ByteBufReader) ReadBytes ¶
func (r *ByteBufReader) ReadBytes(length int) []byte
ReadBytes reads fixed-length bytes from the buffer
func (*ByteBufReader) ReadLenBytes ¶
func (r *ByteBufReader) ReadLenBytes() (length int, key []byte)
ReadLenBytes reads a key containing length and bytes from the buffer
func (*ByteBufReader) ReadUint32 ¶
func (r *ByteBufReader) ReadUint32() uint32
ReadUint32 reads uint32 from the buffer
func (*ByteBufReader) ReadUvarint64 ¶
func (r *ByteBufReader) ReadUvarint64() uint64
ReadUvarint64 reads variable-length positive int from the buffer
func (*ByteBufReader) SubArray ¶
func (r *ByteBufReader) SubArray(start int) []byte
SubArray means to get the byte array from start