buffer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BufferOverreadError represents an instance in which a read
	// attempted to read past the buffer itself
	BufferSeekError = BufferError{
					// contains filtered or unexported fields
	}
	// BufferOverreadError represents an instance in which a read
	// attempted to read past the buffer itself
	BufferOverreadError = BufferError{
						// contains filtered or unexported fields
	}

	// BufferUnderreadError represents an instance in which a read
	// attempted to read before the buffer itself
	BufferUnderreadError = BufferError{
							// contains filtered or unexported fields
	}

	// BufferOverwriteError represents an instance in which a write
	// attempted to write past the buffer itself
	BufferOverwriteError = BufferError{
							// contains filtered or unexported fields
	}

	// BufferUnderwriteError represents an instance in which a write
	// attempted to write before the buffer itself
	BufferUnderwriteError = BufferError{
							// contains filtered or unexported fields
	}

	// BufferInvalidByteCountError represents an instance in which an
	// invalid byte count was passed to one of the buffer's methods
	BufferInvalidByteCountError = BufferError{
								// contains filtered or unexported fields
	}

	// BytesBufNegativeReadError represents an instance in which a
	// reader returned a negative count from its Read method
	BytesBufNegativeReadError = BufferError{
								// contains filtered or unexported fields
	}
)

Functions

func ByteLenVarInt

func ByteLenVarInt(x int64) int64

ByteLenVarInt get size of varint number

func ByteLenVarUint

func ByteLenVarUint(x uint64) int64

*****************

  • Varint Routine * *****************

ByteLenVarUint get size of varuint number

Types

type Buffer

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

Buffer a buffer instance

func Create

func Create(size int64) *Buffer

Create a new Buffer with buffer size

func From

func From(data []byte) *Buffer

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns internal byte slice of the buffer

func (*Buffer) Capacity

func (b *Buffer) Capacity() int64

Capacity returns the capacity of the buffer

func (*Buffer) EnsureCap

func (b *Buffer) EnsureCap(n int64)

EnsureCap ensure there are enough capacity to access

func (*Buffer) Grow

func (b *Buffer) Grow(n int64)

Grow makes the buffer's capacity bigger by n bytes

func (*Buffer) Offset

func (b *Buffer) Offset() int64

Offset returns current offset of the buffer

func (*Buffer) ReadByte

func (b *Buffer) ReadByte() byte

func (*Buffer) ReadBytes

func (b *Buffer) ReadBytes(n int64) []byte

func (*Buffer) ReadFloat32BE

func (b *Buffer) ReadFloat32BE() float32

func (*Buffer) ReadFloat32LE

func (b *Buffer) ReadFloat32LE() float32

func (*Buffer) ReadFloat64BE

func (b *Buffer) ReadFloat64BE() float64

func (*Buffer) ReadFloat64LE

func (b *Buffer) ReadFloat64LE() float64

func (*Buffer) ReadInt16BE

func (b *Buffer) ReadInt16BE() int16

func (*Buffer) ReadInt16LE

func (b *Buffer) ReadInt16LE() int16

func (*Buffer) ReadInt32BE

func (b *Buffer) ReadInt32BE() int32

func (*Buffer) ReadInt32LE

func (b *Buffer) ReadInt32LE() int32

func (*Buffer) ReadInt64BE

func (b *Buffer) ReadInt64BE() int64

func (*Buffer) ReadInt64LE

func (b *Buffer) ReadInt64LE() int64

func (*Buffer) ReadInt8

func (b *Buffer) ReadInt8() int8

func (*Buffer) ReadString

func (b *Buffer) ReadString() string

ReadString reads packed string from the buffer at the current offset and moves the offset forward the amount of bytes read. Retrurns string instance

func (*Buffer) ReadStringPtr

func (b *Buffer) ReadStringPtr() *string

ReadStringPtr reads packed string from the buffer at the current offset and moves the offset forward the amount of bytes read Retrurns pointer of string instance

func (*Buffer) ReadUint16BE

func (b *Buffer) ReadUint16BE() uint16

func (*Buffer) ReadUint16LE

func (b *Buffer) ReadUint16LE() uint16

func (*Buffer) ReadUint32BE

func (b *Buffer) ReadUint32BE() uint32

func (*Buffer) ReadUint32LE

func (b *Buffer) ReadUint32LE() uint32

func (*Buffer) ReadUint64BE

func (b *Buffer) ReadUint64BE() uint64

func (*Buffer) ReadUint64LE

func (b *Buffer) ReadUint64LE() uint64

func (*Buffer) ReadUint8

func (b *Buffer) ReadUint8() uint8

func (*Buffer) ReadVarInt

func (b *Buffer) ReadVarInt() (int64, int)

ReadVarInt reads a varuint from the buffer at the current offset and moves the offset forward the amount of bytes read

func (*Buffer) ReadVarUint

func (b *Buffer) ReadVarUint() (uint64, int)

ReadVarUint reads a varuint from the buffer at the current offset and moves the offset forward the amount of bytes read

func (*Buffer) Seal

func (b *Buffer) Seal() []byte

Seal return slice which seals to current offset

func (*Buffer) Seek

func (b *Buffer) Seek(offset int64, relative bool)

Seek seeks to position off of the buffer

func (*Buffer) UnsafeSeek

func (b *Buffer) UnsafeSeek(offset int64, relative bool)

UnsafeSeek seeks to position off of the buffer without boundary checking

func (*Buffer) Update

func (b *Buffer) Update()

func (*Buffer) WriteByte

func (b *Buffer) WriteByte(data byte)

WriteByte writes byte to the buffer at the current offset and moves forward the amount of bytes written nolint

func (*Buffer) WriteBytes

func (b *Buffer) WriteBytes(data []byte)

WriteBytes writes bytes to the buffer at the current offset and moves forward the amount of bytes written

func (*Buffer) WriteFloat32BE

func (b *Buffer) WriteFloat32BE(data float32)

func (*Buffer) WriteFloat32LE

func (b *Buffer) WriteFloat32LE(data float32)

func (*Buffer) WriteFloat64BE

func (b *Buffer) WriteFloat64BE(data float64)

func (*Buffer) WriteFloat64LE

func (b *Buffer) WriteFloat64LE(data float64)

func (*Buffer) WriteInt16BE

func (b *Buffer) WriteInt16BE(data int16)

func (*Buffer) WriteInt16LE

func (b *Buffer) WriteInt16LE(data int16)

func (*Buffer) WriteInt32BE

func (b *Buffer) WriteInt32BE(data int32)

func (*Buffer) WriteInt32LE

func (b *Buffer) WriteInt32LE(data int32)

func (*Buffer) WriteInt64BE

func (b *Buffer) WriteInt64BE(data int64)

func (*Buffer) WriteInt64LE

func (b *Buffer) WriteInt64LE(data int64)

func (*Buffer) WriteInt8

func (b *Buffer) WriteInt8(data int8)

func (*Buffer) WriteString

func (b *Buffer) WriteString(str *string)

func (*Buffer) WriteUint16BE

func (b *Buffer) WriteUint16BE(data uint16)

func (*Buffer) WriteUint16LE

func (b *Buffer) WriteUint16LE(data uint16)

func (*Buffer) WriteUint32BE

func (b *Buffer) WriteUint32BE(data uint32)

func (*Buffer) WriteUint32LE

func (b *Buffer) WriteUint32LE(data uint32)

func (*Buffer) WriteUint64BE

func (b *Buffer) WriteUint64BE(data uint64)

func (*Buffer) WriteUint64LE

func (b *Buffer) WriteUint64LE(data uint64)

func (*Buffer) WriteUint8

func (b *Buffer) WriteUint8(data uint8)

func (*Buffer) WriteVarInt

func (b *Buffer) WriteVarInt(x int64) int64

WriteVarInt write varint to the buffer at the current offset and moves the offset forward the amount of bytes written. Returns number of bytes written

func (*Buffer) WriteVarUint

func (b *Buffer) WriteVarUint(x uint64) int64

WriteVarUint write varuint to the buffer at the current offset and moves the offset forward the amount of bytes written. Returns number of bytes written

type BufferError

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

Error implements custom error in buffer

func (BufferError) Error

func (e BufferError) Error() string

Error formats BufferError as string

Jump to

Keyboard shortcuts

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