stream

package
v0.0.0-...-034a78d Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

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

func BinaryBufWriter(buffer []byte) *Binary

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

func BinaryReader(v []byte) *Binary

BinaryReader create binary stream for reading data

func BinaryWriter

func BinaryWriter() *Binary

BinaryWriter create binary stream for writing data

func (*Binary) Bytes

func (b *Binary) Bytes() ([]byte, error)

Bytes returns memory buffer data, if error return err

func (*Binary) Empty

func (b *Binary) Empty() bool

Empty reports whether the unread portion of the buffer is empty.

func (*Binary) Error

func (b *Binary) Error() error

Error return binary err

func (*Binary) Len

func (b *Binary) Len() int

Len returns the number of bytes of the unread portion of the buffer;

func (*Binary) PutByte

func (b *Binary) PutByte(v byte)

PutByte encodes a byte into buf

func (*Binary) PutBytes

func (b *Binary) PutBytes(v []byte)

PutBytes encodes bytes into buf

func (*Binary) PutInt32

func (b *Binary) PutInt32(v int32)

PutInt32 encodes a int32 as 4 bytes into buf

func (*Binary) PutInt64

func (b *Binary) PutInt64(v int64)

PutInt64 encodes a int64 as 8 bytes into buf

func (*Binary) PutLenBytes

func (b *Binary) PutLenBytes(data []byte)

PutLenBytes encodes data as length(Uvarint64) + data

func (*Binary) PutUint32

func (b *Binary) PutUint32(v uint32)

PutUint32 encodes a uint32 as 4 bytes into buf

func (*Binary) PutUint64

func (b *Binary) PutUint64(v uint64)

PutUint64 encodes a int64 as 8 bytes into buf

func (*Binary) PutUvarint32

func (b *Binary) PutUvarint32(v uint32)

PutUvarint32 encodes a uint32 into buf

func (*Binary) PutUvarint64

func (b *Binary) PutUvarint64(v uint64)

PutUvarint64 encodes a uint64 into buf

func (*Binary) PutVarint32

func (b *Binary) PutVarint32(v int32)

PutVarint32 encodes a int32 into buf

func (*Binary) PutVarint64

func (b *Binary) PutVarint64(v int64)

PutVarint64 encodes a int64 into buf

func (*Binary) ReadBytes

func (b *Binary) ReadBytes(n int) []byte

ReadBytes reads n len bytes, use buf.Next()

func (*Binary) ReadInt32

func (b *Binary) ReadInt32() int32

ReadInt32 read 4 bytes from buf as int32

func (*Binary) ReadInt64

func (b *Binary) ReadInt64() int64

ReadInt64 read 8 bytes from buf as int64

func (*Binary) ReadUint32

func (b *Binary) ReadUint32() uint32

ReadUint32 read 4 bytes from buf as uint32

func (*Binary) ReadUint64

func (b *Binary) ReadUint64() uint64

ReadUint64 read 8 bytes from buf as uint64

func (*Binary) ReadUvarint32

func (b *Binary) ReadUvarint32() uint32

ReadUvarint32 reads uint32 from buffer

func (*Binary) ReadUvarint64

func (b *Binary) ReadUvarint64() uint64

ReadUvarint64 reads uint64 from buffer

func (*Binary) ReadVarint32

func (b *Binary) ReadVarint32() int32

ReadVarint32 reads int32 from buffer

func (*Binary) ReadVarint64

func (b *Binary) ReadVarint64() int64

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

Jump to

Keyboard shortcuts

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