Documentation ¶
Index ¶
- Variables
- func CombineBuffers(elements ...[][]byte) [][]byte
- type ByteRef
- type BytesRef
- type ReadBuffer
- func (r *ReadBuffer) BytesRemaining() int
- func (r *ReadBuffer) CurrentPos() int
- func (r *ReadBuffer) FillFrom(ior io.Reader, n int) (int, error)
- func (r *ReadBuffer) ReadByte() (byte, error)
- func (r *ReadBuffer) ReadBytes(n int) ([]byte, error)
- func (r *ReadBuffer) ReadString(n int) (string, error)
- func (r *ReadBuffer) ReadUint16() (uint16, error)
- func (r *ReadBuffer) ReadUint32() (uint32, error)
- func (r *ReadBuffer) ReadUint64() (uint64, error)
- func (r *ReadBuffer) Seek(offset int) error
- func (r *ReadBuffer) Wrap(b []byte)
- type Uint16Ref
- type Uint32Ref
- type Uint64Ref
- type WriteBuffer
- func (w *WriteBuffer) BytesRemaining() int
- func (w *WriteBuffer) BytesWritten() int
- func (w *WriteBuffer) CurrentPos() int
- func (w *WriteBuffer) DeferByte() (ByteRef, error)
- func (w *WriteBuffer) DeferBytes(n int) (BytesRef, error)
- func (w *WriteBuffer) DeferUint16() (Uint16Ref, error)
- func (w *WriteBuffer) DeferUint32() (Uint32Ref, error)
- func (w *WriteBuffer) DeferUint64() (Uint64Ref, error)
- func (w *WriteBuffer) FlushTo(iow io.Writer) (int, error)
- func (w *WriteBuffer) Reset()
- func (w *WriteBuffer) Seek(offset int) error
- func (w *WriteBuffer) Wrap(b []byte)
- func (w *WriteBuffer) WriteByte(n byte) error
- func (w *WriteBuffer) WriteBytes(b []byte) error
- func (w *WriteBuffer) WriteString(s string) error
- func (w *WriteBuffer) WriteUint16(n uint16) error
- func (w *WriteBuffer) WriteUint32(n uint32) error
- func (w *WriteBuffer) WriteUint64(n uint64) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInsufficientBuffer = errors.New("buffer is too small") ErrBufferFull = errors.New("no more room in buffer") )
Functions ¶
func CombineBuffers ¶
Types ¶
type BytesRef ¶
type BytesRef []byte
A BytesRef is a reference to a multi-byte placeholder in a buffer
func (BytesRef) UpdateString ¶
UpdateString updates the bytes in the buffer from a string
type ReadBuffer ¶
type ReadBuffer struct {
// contains filtered or unexported fields
}
A typed.ReadBuffer is a wrapper around an underlying []byte with methods to read from that buffer in big-endian format.
func NewReadBuffer ¶
func NewReadBuffer(buffer []byte) *ReadBuffer
NewReadBuffer returns a ReadBuffer wrapping a byte slice
func NewReadBufferWithSize ¶
func NewReadBufferWithSize(size int) *ReadBuffer
NewReadBufferWithSize returns a ReadBuffer with a given capacity
func (*ReadBuffer) BytesRemaining ¶
func (r *ReadBuffer) BytesRemaining() int
BytesRemaining returns the number of unconsumed bytes remaining in the buffer
func (*ReadBuffer) CurrentPos ¶
func (r *ReadBuffer) CurrentPos() int
CurrentPos returns the current read position within the buffer
func (*ReadBuffer) ReadByte ¶
func (r *ReadBuffer) ReadByte() (byte, error)
ReadByte reads the next byte from the buffer
func (*ReadBuffer) ReadBytes ¶
func (r *ReadBuffer) ReadBytes(n int) ([]byte, error)
ReadBytes returns the next n bytes from the buffer
func (*ReadBuffer) ReadString ¶
func (r *ReadBuffer) ReadString(n int) (string, error)
ReadString returns a string of size n from the buffer
func (*ReadBuffer) ReadUint16 ¶
func (r *ReadBuffer) ReadUint16() (uint16, error)
ReadUint16 returns the next value in the buffer as a uint16
func (*ReadBuffer) ReadUint32 ¶
func (r *ReadBuffer) ReadUint32() (uint32, error)
ReadUint32 returns the next value in the buffer as a uint32
func (*ReadBuffer) ReadUint64 ¶
func (r *ReadBuffer) ReadUint64() (uint64, error)
ReadUint64 returns the next value in the buffer as a uint64
func (*ReadBuffer) Seek ¶
func (r *ReadBuffer) Seek(offset int) error
Seek moves the current read position to the given offset in the buffer
func (*ReadBuffer) Wrap ¶
func (r *ReadBuffer) Wrap(b []byte)
Wrap initializes the buffer to read from the given byte slice
type Uint16Ref ¶
type Uint16Ref []byte
A Uint16Ref is a reference to a uint16 placeholder in a buffer
type Uint32Ref ¶
type Uint32Ref []byte
A Uint32Ref is a reference to a uint32 placeholder in a buffer
type Uint64Ref ¶
type Uint64Ref []byte
A Uint64Ref is a reference to a uin64 placeholder in a buffer
type WriteBuffer ¶
type WriteBuffer struct {
// contains filtered or unexported fields
}
A typed.WriteBuffer is a wrapper around an underlying []byte with methods to write to that buffer in big-endian format. The buffer is of fixed size, and does not grow.
func NewWriteBuffer ¶
func NewWriteBuffer(buffer []byte) *WriteBuffer
NewWriteBuffer creates a WriteBuffer wrapping the given slice
func NewWriteBufferWithSize ¶
func NewWriteBufferWithSize(size int) *WriteBuffer
NewWriteBufferWithSize create a new WriteBuffer using an internal buffer of the given size
func (*WriteBuffer) BytesRemaining ¶
func (w *WriteBuffer) BytesRemaining() int
BytesRemaining returns the number of available bytes remaining in the bufffer
func (*WriteBuffer) BytesWritten ¶
func (w *WriteBuffer) BytesWritten() int
BytesWritten returns the number of bytes that have been written to the buffer
func (*WriteBuffer) CurrentPos ¶
func (w *WriteBuffer) CurrentPos() int
CurrentPos returns the current write position in the buffer
func (*WriteBuffer) DeferByte ¶
func (w *WriteBuffer) DeferByte() (ByteRef, error)
DeferByte reserves space in the buffer for a single byte, and returns a reference that can be used to update that byte later
func (*WriteBuffer) DeferBytes ¶
func (w *WriteBuffer) DeferBytes(n int) (BytesRef, error)
DeferBytes reserves space in the buffer for a fixed sequence of bytes, and returns a reference that can be used to update those bytes
func (*WriteBuffer) DeferUint16 ¶
func (w *WriteBuffer) DeferUint16() (Uint16Ref, error)
DeferUint16 reserves space in the buffer for a uint16, and returns a reference that can be used to update that uint16
func (*WriteBuffer) DeferUint32 ¶
func (w *WriteBuffer) DeferUint32() (Uint32Ref, error)
DeferUint32 reserves space in the buffer for a uint32, and returns a reference that can be used to update that uint32
func (*WriteBuffer) DeferUint64 ¶
func (w *WriteBuffer) DeferUint64() (Uint64Ref, error)
DeferUint64 reserves space in the buffer for a uint64, and returns a reference that can be used to update that uint64
func (*WriteBuffer) FlushTo ¶
func (w *WriteBuffer) FlushTo(iow io.Writer) (int, error)
FlushTo flushes the written buffer to the given writer
func (*WriteBuffer) Reset ¶
func (w *WriteBuffer) Reset()
Reset resets the buffer to an empty state, ready for writing
func (*WriteBuffer) Seek ¶
func (w *WriteBuffer) Seek(offset int) error
Seek moves the current write position to the given offset in the buffer
func (*WriteBuffer) Wrap ¶
func (w *WriteBuffer) Wrap(b []byte)
Wrap initializes the buffer to wrap the given byte slice
func (*WriteBuffer) WriteByte ¶
func (w *WriteBuffer) WriteByte(n byte) error
WriteByte writes a single byte to the buffer
func (*WriteBuffer) WriteBytes ¶
func (w *WriteBuffer) WriteBytes(b []byte) error
WriteBytes writes a slice of bytes to the buffer
func (*WriteBuffer) WriteString ¶
func (w *WriteBuffer) WriteString(s string) error
WriteString writes a string to the buffer
func (*WriteBuffer) WriteUint16 ¶
func (w *WriteBuffer) WriteUint16(n uint16) error
WriteUint16 writes a big endian encoded uint16 value to the buffer
func (*WriteBuffer) WriteUint32 ¶
func (w *WriteBuffer) WriteUint32(n uint32) error
WriteUint32 writes a big endian uint32 value to the buffer
func (*WriteBuffer) WriteUint64 ¶
func (w *WriteBuffer) WriteUint64(n uint64) error
WriteUint64 writes a big endian uint64 to the buffer