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 ¶
- Variables
- func ByteLenVarInt(x int64) int64
- func ByteLenVarUint(x uint64) int64
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Capacity() int64
- func (b *Buffer) EnsureCap(n int64)
- func (b *Buffer) Grow(n int64)
- func (b *Buffer) Offset() int64
- func (b *Buffer) ReadByte() byte
- func (b *Buffer) ReadByteUnsafe() byte
- func (b *Buffer) ReadBytes(n int64) []byte
- func (b *Buffer) ReadBytesUnsafe(n int64) []byte
- func (b *Buffer) ReadFloat32BE() float32
- func (b *Buffer) ReadFloat32BEUnsafe() float32
- func (b *Buffer) ReadFloat32LE() float32
- func (b *Buffer) ReadFloat32LEUnsafe() float32
- func (b *Buffer) ReadFloat64BE() float64
- func (b *Buffer) ReadFloat64BEUnsafe() float64
- func (b *Buffer) ReadFloat64LE() float64
- func (b *Buffer) ReadFloat64LEUnsafe() float64
- func (b *Buffer) ReadInt16BE() int16
- func (b *Buffer) ReadInt16BEUnsafe() int16
- func (b *Buffer) ReadInt16LE() int16
- func (b *Buffer) ReadInt16LEUnsafe() int16
- func (b *Buffer) ReadInt32BE() int32
- func (b *Buffer) ReadInt32BEUnsafe() int32
- func (b *Buffer) ReadInt32LE() int32
- func (b *Buffer) ReadInt32LEUnsafe() int32
- func (b *Buffer) ReadInt64BE() int64
- func (b *Buffer) ReadInt64BEUnsafe() int64
- func (b *Buffer) ReadInt64LE() int64
- func (b *Buffer) ReadInt64LEUnsafe() int64
- func (b *Buffer) ReadInt8() int8
- func (b *Buffer) ReadInt8Unsafe() int8
- func (b *Buffer) ReadString() string
- func (b *Buffer) ReadStringPtr() *string
- func (b *Buffer) ReadUint16BE() uint16
- func (b *Buffer) ReadUint16BEUnsafe() uint16
- func (b *Buffer) ReadUint16LE() uint16
- func (b *Buffer) ReadUint16LEUnsafe() uint16
- func (b *Buffer) ReadUint32BE() uint32
- func (b *Buffer) ReadUint32BEUnsafe() uint32
- func (b *Buffer) ReadUint32LE() uint32
- func (b *Buffer) ReadUint32LEUnsafe() uint32
- func (b *Buffer) ReadUint64BE() uint64
- func (b *Buffer) ReadUint64BEUnsafe() uint64
- func (b *Buffer) ReadUint64LE() uint64
- func (b *Buffer) ReadUint64LEUnsafe() uint64
- func (b *Buffer) ReadUint8() uint8
- func (b *Buffer) ReadUint8Unsafe() uint8
- func (b *Buffer) ReadVarInt() (int64, int)
- func (b *Buffer) ReadVarUint() (uint64, int)
- func (b *Buffer) Seal() []byte
- func (b *Buffer) Seek(offset int64, relative bool)
- func (b *Buffer) SeekUnsafe(offset int64, relative bool)
- func (b *Buffer) WriteByte(data byte) *Buffer
- func (b *Buffer) WriteBytes(data []byte) *Buffer
- func (b *Buffer) WriteFloat32BE(data float32) *Buffer
- func (b *Buffer) WriteFloat32BEUnsafe(data float32) *Buffer
- func (b *Buffer) WriteFloat32LE(data float32) *Buffer
- func (b *Buffer) WriteFloat32LEUnsafe(data float32) *Buffer
- func (b *Buffer) WriteFloat64BE(data float64) *Buffer
- func (b *Buffer) WriteFloat64BEUnsafe(data float64) *Buffer
- func (b *Buffer) WriteFloat64LE(data float64) *Buffer
- func (b *Buffer) WriteFloat64LEUnsafe(data float64) *Buffer
- func (b *Buffer) WriteInt16BE(data int16) *Buffer
- func (b *Buffer) WriteInt16BEUnsafe(data int16) *Buffer
- func (b *Buffer) WriteInt16LE(data int16) *Buffer
- func (b *Buffer) WriteInt16LEUnsafe(data int16) *Buffer
- func (b *Buffer) WriteInt32BE(data int32) *Buffer
- func (b *Buffer) WriteInt32BEUnsafe(data int32) *Buffer
- func (b *Buffer) WriteInt32LE(data int32) *Buffer
- func (b *Buffer) WriteInt32LEUnsafe(data int32) *Buffer
- func (b *Buffer) WriteInt64BE(data int64) *Buffer
- func (b *Buffer) WriteInt64BEUnsafe(data int64) *Buffer
- func (b *Buffer) WriteInt64LE(data int64) *Buffer
- func (b *Buffer) WriteInt64LEUnsafe(data int64) *Buffer
- func (b *Buffer) WriteInt8(data int8) *Buffer
- func (b *Buffer) WriteInt8Unsafe(data int8) *Buffer
- func (b *Buffer) WriteString(str *string) *Buffer
- func (b *Buffer) WriteUint16BE(data uint16) *Buffer
- func (b *Buffer) WriteUint16BEUnsafe(data uint16) *Buffer
- func (b *Buffer) WriteUint16LE(data uint16) *Buffer
- func (b *Buffer) WriteUint16LEUnsafe(data uint16) *Buffer
- func (b *Buffer) WriteUint32BE(data uint32) *Buffer
- func (b *Buffer) WriteUint32BEUnsafe(data uint32) *Buffer
- func (b *Buffer) WriteUint32LE(data uint32) *Buffer
- func (b *Buffer) WriteUint32LEUnsafe(data uint32) *Buffer
- func (b *Buffer) WriteUint64BE(data uint64) *Buffer
- func (b *Buffer) WriteUint64BEUnsafe(data uint64) *Buffer
- func (b *Buffer) WriteUint64LE(data uint64) *Buffer
- func (b *Buffer) WriteUint64LEUnsafe(data uint64) *Buffer
- func (b *Buffer) WriteUint8(data uint8) *Buffer
- func (b *Buffer) WriteUint8Unsafe(data uint8) *Buffer
- func (b *Buffer) WriteVarInt(x int64) *Buffer
- func (b *Buffer) WriteVarUint(x uint64) *Buffer
- type BufferError
Constants ¶
This section is empty.
Variables ¶
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 ¶
ByteLenVarInt returns the byte length of unsigned variant integer number
func ByteLenVarUint ¶
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 (*Buffer) EnsureCap ¶
EnsureCap ensures there are enough capacity to access, to guarantee space for another n bytes.
func (*Buffer) Grow ¶
Grow grows the buffer's capacity, if necessary, to guarantee space for another n bytes.
func (*Buffer) ReadByte ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
ReadString reads packed string from the buffer at the current offset and moves the offset forward the amount of bytes read.
func (*Buffer) ReadStringPtr ¶
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
ReadVarInt reads a varuint from the buffer at the current offset and moves the offset forward the amount of bytes read
func (*Buffer) ReadVarUint ¶
ReadVarUint reads a varuint from the buffer at the current offset and moves the offset forward the amount of bytes read
func (*Buffer) Seek ¶
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
SeekUnsafe seeks to the offset of the buffer relative to current position or seeks to absolute position. without boundary checking.
func (*Buffer) WriteByte ¶
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 ¶
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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
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 ¶
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 ¶
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