buffer

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package buffer provides a easy way to manipulate byte slices.

It's always annoying to calculate offset, ensure buffer is large enough ...etc, this package wraps annoying operations and lets programmer happy.

Index

Constants

This section is empty.

Variables

View Source
var (
	// BufferSeekError represents an instance in which seek operation
	// attempted to invalid position.
	BufferSeekError = errors.WithStack(&BufferError{
		error: "seek offset is invalid",
	})
	// BufferOverreadError represents an instance in which a read
	// attempted to read past the buffer itself.
	BufferOverreadError = errors.WithStack(&BufferError{
		error: "read exceeds buffer capacity",
	})

	// BufferUnderreadError represents an instance in which a read
	// attempted to read before the buffer itself.
	BufferUnderreadError = errors.WithStack(&BufferError{
		error: "read offset is less than zero",
	})

	// BufferOverwriteError represents an instance in which a write
	// attempted to write past the buffer itself.
	BufferOverwriteError = errors.WithStack(&BufferError{
		error: "write offset exceeds buffer capacity",
	})

	// BufferUnderwriteError represents an instance in which a write
	// attempted to write before the buffer itself.
	BufferUnderwriteError = errors.WithStack(&BufferError{
		error: "write offset is less than zero",
	})

	// BufferInvalidByteCountError represents an instance in which an
	// invalid byte count was passed to one of the buffer's methods.
	BufferInvalidByteCountError = errors.WithStack(&BufferError{
		error: "invalid byte count requested",
	})

	// BytesBufNegativeReadError represents an instance in which a
	// reader returned a negative count from its Read method.
	BytesBufNegativeReadError = errors.WithStack(&BufferError{
		error: "reader returned negative count from Read",
	})
)

Functions

func ByteLenVarInt

func ByteLenVarInt(x int64) int64

ByteLenVarInt returns the byte length of unsigned variant integer number

func ByteLenVarUint

func ByteLenVarUint(x uint64) int64

ByteLenVarUint returns the byte length of variant integer number

Types

type Buffer

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

Buffer is a variable-sized buffer of bytes, provides methods for generic buffer operations

func Create

func Create(size int64) *Buffer

Create a new Buffer with buffer size

func From

func From(data []byte) *Buffer

From returns a buffer instance with the byte slice provided.

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 ensures there are enough capacity to access, to guarantee space for another n bytes.

func (*Buffer) Grow

func (b *Buffer) Grow(n int64)

Grow grows the buffer's capacity, if necessary, to guarantee space for another 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

ReadByte reads a byte from the buffer at current offset and moves the offset forward 1 byte.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadByteUnsafe added in v1.0.2

func (b *Buffer) ReadByteUnsafe() byte

ReadByteUnsafe reads a byte from the buffer at current offset and moves the offset forward 1 byte.

This method doesn't check the read safety.

func (*Buffer) ReadBytes

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

ReadBytes reads n bytes from the buffer at current offset and moves the offset forward n byte.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadBytesUnsafe added in v1.0.2

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

ReadBytesUnsafe reads n bytes from the buffer at current offset and moves the offset forward n byte.

This method doesn't check the read safety.

func (*Buffer) ReadFloat32BE

func (b *Buffer) ReadFloat32BE() float32

ReadFloat32BE reads float32 from the buffer at current offset in big-endian and moves the offset forward 4 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadFloat32BEUnsafe added in v1.0.2

func (b *Buffer) ReadFloat32BEUnsafe() float32

ReadFloat32BEUnsafe reads float32 from the buffer at current offset in big-endian and moves the offset forward 4 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadFloat32LE

func (b *Buffer) ReadFloat32LE() float32

ReadFloat32LE reads float32 from the buffer at current offset in little-endian and moves the offset forward 4 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadFloat32LEUnsafe added in v1.0.2

func (b *Buffer) ReadFloat32LEUnsafe() float32

ReadFloat32LEUnsafe reads float32 from the buffer at current offset in little-endian and moves the offset forward 4 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadFloat64BE

func (b *Buffer) ReadFloat64BE() float64

ReadFloat64BE reads float64 from the buffer at current offset in big-endian and moves the offset forward 8 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadFloat64BEUnsafe added in v1.0.2

func (b *Buffer) ReadFloat64BEUnsafe() float64

ReadFloat64BEUnsafe reads float64 from the buffer at current offset in big-endian and moves the offset forward 8 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadFloat64LE

func (b *Buffer) ReadFloat64LE() float64

ReadFloat64LE reads float64 from the buffer at current offset in little-endian and moves the offset forward 8 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadFloat64LEUnsafe added in v1.0.2

func (b *Buffer) ReadFloat64LEUnsafe() float64

ReadFloat64LEUnsafe reads float64 from the buffer at current offset in little-endian and moves the offset forward 8 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadInt16BE

func (b *Buffer) ReadInt16BE() int16

ReadInt16BE reads int16 from the buffer at current offset in big-endian and moves the offset forward 2 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadInt16BEUnsafe added in v1.0.2

func (b *Buffer) ReadInt16BEUnsafe() int16

ReadInt16BEUnsafe reads int16 from the buffer at current offset in big-endian and moves the offset forward 2 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadInt16LE

func (b *Buffer) ReadInt16LE() int16

ReadInt16LE reads int16 from the buffer at current offset in little-endian and moves the offset forward 2 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadInt16LEUnsafe added in v1.0.2

func (b *Buffer) ReadInt16LEUnsafe() int16

ReadInt16LEUnsafe reads int16 from the buffer at current offset in little-endian and moves the offset forward 2 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadInt32BE

func (b *Buffer) ReadInt32BE() int32

ReadInt32BE reads int32 from the buffer at current offset in big-endian and moves the offset forward 4 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadInt32BEUnsafe added in v1.0.2

func (b *Buffer) ReadInt32BEUnsafe() int32

ReadInt32BEUnsafe reads int32 from the buffer at current offset in big-endian and moves the offset forward 4 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadInt32LE

func (b *Buffer) ReadInt32LE() int32

ReadInt32LE reads int32 from the buffer at current offset in little-endian and moves the offset forward 4 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadInt32LEUnsafe added in v1.0.2

func (b *Buffer) ReadInt32LEUnsafe() int32

ReadInt32LEUnsafe reads int32 from the buffer at current offset in little-endian and moves the offset forward 4 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadInt64BE

func (b *Buffer) ReadInt64BE() int64

ReadInt64BE reads int64 from the buffer at current offset in big-endian and moves the offset forward 8 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadInt64BEUnsafe added in v1.0.2

func (b *Buffer) ReadInt64BEUnsafe() int64

ReadInt64BEUnsafe reads int64 from the buffer at current offset in big-endian and moves the offset forward 8 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadInt64LE

func (b *Buffer) ReadInt64LE() int64

ReadInt64LE reads int64 from the buffer at current offset in little-endian and moves the offset forward 8 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadInt64LEUnsafe added in v1.0.2

func (b *Buffer) ReadInt64LEUnsafe() int64

ReadInt64LEUnsafe reads int64 from the buffer at current offset in little-endian and moves the offset forward 8 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadInt8

func (b *Buffer) ReadInt8() int8

ReadInt8 reads int8 from the buffer at current offset and moves the offset forward 1 byte.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadInt8Unsafe added in v1.0.2

func (b *Buffer) ReadInt8Unsafe() int8

ReadInt8Unsafe reads int8 from the buffer at current offset and moves the offset forward 1 byte

This method doesn't check the read safety.

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.

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

ReadUint16BE reads uint16 from the buffer at current offset in big-endian and moves the offset forward 2 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadUint16BEUnsafe added in v1.0.2

func (b *Buffer) ReadUint16BEUnsafe() uint16

ReadUint16BEUnsafe reads uint16 from the buffer at current offset in big-endian and moves the offset forward 2 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadUint16LE

func (b *Buffer) ReadUint16LE() uint16

ReadUint16LE reads uint16 from the buffer at current offset in little-endian and moves the offset forward 2 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadUint16LEUnsafe added in v1.0.2

func (b *Buffer) ReadUint16LEUnsafe() uint16

ReadUint16LEUnsafe reads uint16 from the buffer at current offset in little-endian and moves the offset forward 2 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadUint32BE

func (b *Buffer) ReadUint32BE() uint32

ReadUint32BE reads uint32 from the buffer at current offset in big-endian and moves the offset forward 4 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadUint32BEUnsafe added in v1.0.2

func (b *Buffer) ReadUint32BEUnsafe() uint32

ReadUint32BEUnsafe reads uint32 from the buffer at current offset in big-endian and moves the offset forward 4 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadUint32LE

func (b *Buffer) ReadUint32LE() uint32

ReadUint32LE reads uint32 from the buffer at current offset in little-endian and moves the offset forward 4 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadUint32LEUnsafe added in v1.0.2

func (b *Buffer) ReadUint32LEUnsafe() uint32

ReadUint32LEUnsafe reads uint32 from the buffer at current offset in little-endian and moves the offset forward 4 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadUint64BE

func (b *Buffer) ReadUint64BE() uint64

ReadUint64BE reads uint64 from the buffer at current offset in big-endian and moves the offset forward 8 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadUint64BEUnsafe added in v1.0.2

func (b *Buffer) ReadUint64BEUnsafe() uint64

ReadUint64BEUnsafe reads uint64 from the buffer at current offset in big-endian and moves the offset forward 8 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadUint64LE

func (b *Buffer) ReadUint64LE() uint64

ReadUint64LE reads uint64 from the buffer at current offset in little-endian and moves the offset forward 8 bytes.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadUint64LEUnsafe added in v1.0.2

func (b *Buffer) ReadUint64LEUnsafe() uint64

ReadUint64LEUnsafe reads uint64 from the buffer at current offset in little-endian and moves the offset forward 8 bytes.

This method doesn't check the read safety.

func (*Buffer) ReadUint8

func (b *Buffer) ReadUint8() uint8

ReadUint8 reads uint8 from the buffer at current offset and moves the offset forward 1 byte.

If the offset is invalid or not safe to read data, it will panic with BufferOverreadError or BufferUnderreadError.

func (*Buffer) ReadUint8Unsafe added in v1.0.2

func (b *Buffer) ReadUint8Unsafe() uint8

ReadUint8Unsafe reads uint8 from the buffer at current offset and moves the offset forward 1 byte

This method doesn't check the read safety.

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 returns the slice of bytes which seals to current offset

func (*Buffer) Seek

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

Seek seeks to the offset of the buffer relative to current position or seeks to absolute position.

func (*Buffer) SeekUnsafe added in v1.0.2

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

SeekUnsafe seeks to the offset of the buffer relative to current position or seeks to absolute position. without boundary checking.

func (*Buffer) WriteByte

func (b *Buffer) WriteByte(data byte) *Buffer

WriteByte writes a byte to the buffer at current offset and moves the offset forward 1 byte.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteBytes

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

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

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteFloat32BE

func (b *Buffer) WriteFloat32BE(data float32) *Buffer

WriteFloat32BE writes float32 to the buffer at current offset in big-endian and moves the offset forward 4 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteFloat32BEUnsafe added in v1.0.2

func (b *Buffer) WriteFloat32BEUnsafe(data float32) *Buffer

WriteFloat32BEUnsafe writes float32 to the buffer at current offset in big-endian and moves the offset forward 4 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteFloat32LE

func (b *Buffer) WriteFloat32LE(data float32) *Buffer

WriteFloat32LE writes float32 to the buffer at current offset in little-endian and moves the offset forward 4 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteFloat32LEUnsafe added in v1.0.2

func (b *Buffer) WriteFloat32LEUnsafe(data float32) *Buffer

WriteFloat32LEUnsafe writes float32 to the buffer at current offset in little-endian and moves the offset forward 4 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteFloat64BE

func (b *Buffer) WriteFloat64BE(data float64) *Buffer

WriteFloat64BE writes float64 to the buffer at current offset in big-endian and moves the offset forward 8 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteFloat64BEUnsafe added in v1.0.2

func (b *Buffer) WriteFloat64BEUnsafe(data float64) *Buffer

WriteFloat64BEUnsafe writes float64 to the buffer at current offset in big-endian and moves the offset forward 8 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteFloat64LE

func (b *Buffer) WriteFloat64LE(data float64) *Buffer

WriteFloat64LE writes float64 to the buffer at current offset in little-endian and moves the offset forward 8 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteFloat64LEUnsafe added in v1.0.2

func (b *Buffer) WriteFloat64LEUnsafe(data float64) *Buffer

WriteFloat64LEUnsafe writes float64 to the buffer at current offset in little-endian and moves the offset forward 8 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt16BE

func (b *Buffer) WriteInt16BE(data int16) *Buffer

WriteInt16BE writes int16 to the buffer at current offset in big-endian and moves the offset forward 2 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt16BEUnsafe added in v1.0.2

func (b *Buffer) WriteInt16BEUnsafe(data int16) *Buffer

WriteInt16BEUnsafe writes int16 to the buffer at current offset in big-endian and moves the offset forward 2 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt16LE

func (b *Buffer) WriteInt16LE(data int16) *Buffer

WriteInt16LE writes int16 to the buffer at current offset in little-endian and moves the offset forward 2 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt16LEUnsafe added in v1.0.2

func (b *Buffer) WriteInt16LEUnsafe(data int16) *Buffer

WriteInt16LEUnsafe writes int16 to the buffer at current offset in little-endian and moves the offset forward 2 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt32BE

func (b *Buffer) WriteInt32BE(data int32) *Buffer

WriteInt32BE writes int32 to the buffer at current offset in big-endian and moves the offset forward 4 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt32BEUnsafe added in v1.0.2

func (b *Buffer) WriteInt32BEUnsafe(data int32) *Buffer

WriteInt32BEUnsafe writes int32 to the buffer at current offset in big-endian and moves the offset forward 4 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt32LE

func (b *Buffer) WriteInt32LE(data int32) *Buffer

WriteInt32LE writes int32 to the buffer at current offset in little-endian and moves the offset forward 4 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt32LEUnsafe added in v1.0.2

func (b *Buffer) WriteInt32LEUnsafe(data int32) *Buffer

WriteInt32LEUnsafe writes int32 to the buffer at current offset in little-endian and moves the offset forward 4 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt64BE

func (b *Buffer) WriteInt64BE(data int64) *Buffer

WriteInt64BE writes int64 to the buffer at current offset in big-endian and moves the offset forward 8 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt64BEUnsafe added in v1.0.2

func (b *Buffer) WriteInt64BEUnsafe(data int64) *Buffer

WriteInt64BEUnsafe writes int64 to the buffer at current offset in big-endian and moves the offset forward 8 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt64LE

func (b *Buffer) WriteInt64LE(data int64) *Buffer

WriteInt64LE writes int64 to the buffer at current offset in little-endian and moves the offset forward 8 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt64LEUnsafe added in v1.0.2

func (b *Buffer) WriteInt64LEUnsafe(data int64) *Buffer

WriteInt64LEUnsafe writes int64 to the buffer at current offset in little-endian and moves the offset forward 8 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt8

func (b *Buffer) WriteInt8(data int8) *Buffer

WriteInt8 writes int8 to the buffer at current offset and moves the offset forward 1 byte.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteInt8Unsafe added in v1.0.2

func (b *Buffer) WriteInt8Unsafe(data int8) *Buffer

WriteInt8Unsafe writes int8 to the buffer at current offset and moves the offset forward 1 byte

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteString

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

WriteString writes length of string and string data into buffer at current offset and moves the offset forward the amount of bytes written.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint16BE

func (b *Buffer) WriteUint16BE(data uint16) *Buffer

WriteUint16BE writes uint16 to the buffer at current offset in big-endian and moves the offset forward 2 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint16BEUnsafe added in v1.0.2

func (b *Buffer) WriteUint16BEUnsafe(data uint16) *Buffer

WriteUint16BEUnsafe writes uint16 to the buffer at current offset in big-endian and moves the offset forward 2 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint16LE

func (b *Buffer) WriteUint16LE(data uint16) *Buffer

WriteUint16LE writes uint16 to the buffer at current offset in little-endian and moves the offset forward 2 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint16LEUnsafe added in v1.0.2

func (b *Buffer) WriteUint16LEUnsafe(data uint16) *Buffer

WriteUint16LEUnsafe writes uint16 to the buffer at current offset in little-endian and moves the offset forward 2 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint32BE

func (b *Buffer) WriteUint32BE(data uint32) *Buffer

WriteUint32BE writes uint32 to the buffer at current offset in big-endian and moves the offset forward 4 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint32BEUnsafe added in v1.0.2

func (b *Buffer) WriteUint32BEUnsafe(data uint32) *Buffer

WriteUint32BEUnsafe writes uint32 to the buffer at current offset in big-endian and moves the offset forward 4 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint32LE

func (b *Buffer) WriteUint32LE(data uint32) *Buffer

WriteUint32LE writes uint32 to the buffer at current offset in little-endian and moves the offset forward 4 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint32LEUnsafe added in v1.0.2

func (b *Buffer) WriteUint32LEUnsafe(data uint32) *Buffer

WriteUint32LEUnsafe writes uint32 to the buffer at current offset in little-endian and moves the offset forward 4 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint64BE

func (b *Buffer) WriteUint64BE(data uint64) *Buffer

WriteUint64BE writes uint64 to the buffer at current offset in big-endian and moves the offset forward 8 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint64BEUnsafe added in v1.0.2

func (b *Buffer) WriteUint64BEUnsafe(data uint64) *Buffer

WriteUint64BEUnsafe writes uint64 to the buffer at current offset in big-endian and moves the offset forward 8 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint64LE

func (b *Buffer) WriteUint64LE(data uint64) *Buffer

WriteUint64LE writes uint64 to the buffer at current offset in little-endian and moves the offset forward 8 bytes.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint64LEUnsafe added in v1.0.2

func (b *Buffer) WriteUint64LEUnsafe(data uint64) *Buffer

WriteUint64LEUnsafe writes uint64 to the buffer at current offset in little-endian and moves the offset forward 8 bytes.

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint8

func (b *Buffer) WriteUint8(data uint8) *Buffer

WriteUint8 writes uint8 to the buffer at current offset and moves the offset forward 1 byte.

This method will ensure buffer capacity is enough to write data.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteUint8Unsafe added in v1.0.2

func (b *Buffer) WriteUint8Unsafe(data uint8) *Buffer

WriteUint8Unsafe writes uint8 to the buffer at current offset and moves the offset forward 1 byte

This method doesn't check buffer capacity.

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteVarInt

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

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

This method returns current Buffer instance for chainable operation.

func (*Buffer) WriteVarUint

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

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

This method returns current Buffer instance for chainable operation.

type BufferError

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

BufferError represents buffer 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