typed

package
v2.0.0-beta2+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInsufficientBuffer = errors.New("buffer is too small")
	ErrBufferFull         = errors.New("no more room in buffer")
)

Functions

func CombineBuffers

func CombineBuffers(elements ...[][]byte) [][]byte

Types

type ByteRef

type ByteRef []byte

A ByteRef is a reference to a byte in a bufffer

func (ByteRef) Update

func (ref ByteRef) Update(b byte)

Update updates the byte in the buffer

type BytesRef

type BytesRef []byte

A BytesRef is a reference to a multi-byte placeholder in a buffer

func (BytesRef) Update

func (ref BytesRef) Update(b []byte)

Update updates the bytes in the buffer

func (BytesRef) UpdateString

func (ref BytesRef) UpdateString(s string)

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) FillFrom

func (r *ReadBuffer) FillFrom(ior io.Reader, n int) (int, error)

FillFrom fills the buffer from a reader

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

func (Uint16Ref) Update

func (ref Uint16Ref) Update(n uint16)

Update updates the uint16 in the buffer

type Uint32Ref

type Uint32Ref []byte

A Uint32Ref is a reference to a uint32 placeholder in a buffer

func (Uint32Ref) Update

func (ref Uint32Ref) Update(n uint32)

Update updates the uint32 in the buffer

type Uint64Ref

type Uint64Ref []byte

A Uint64Ref is a reference to a uin64 placeholder in a buffer

func (Uint64Ref) Update

func (ref Uint64Ref) Update(n uint64)

Update updates the uint64 in the 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

Jump to

Keyboard shortcuts

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