Documentation ¶
Index ¶
- Variables
- type ByteSlice
- type Decbuf
- func (d *Decbuf) Be32() uint32
- func (d *Decbuf) Be32int() int
- func (d *Decbuf) Be64() uint64
- func (d *Decbuf) Be64Float64() float64
- func (d *Decbuf) Be64int64() int64
- func (d *Decbuf) Byte() byte
- func (d *Decbuf) ConsumePadding()
- func (d *Decbuf) Crc32(castagnoliTable *crc32.Table) uint32
- func (d *Decbuf) Err() error
- func (d *Decbuf) Get() []byte
- func (d *Decbuf) Len() int
- func (d *Decbuf) Skip(l int)
- func (d *Decbuf) Uvarint() int
- func (d *Decbuf) Uvarint64() uint64
- func (d *Decbuf) UvarintBytes() []byte
- func (d *Decbuf) UvarintStr() string
- func (d *Decbuf) Varint64() int64
- type Encbuf
- func (e *Encbuf) Get() []byte
- func (e *Encbuf) Len() int
- func (e *Encbuf) PutBE32(x uint32)
- func (e *Encbuf) PutBE32int(x int)
- func (e *Encbuf) PutBE64(x uint64)
- func (e *Encbuf) PutBE64int64(x int64)
- func (e *Encbuf) PutBEFloat64(x float64)
- func (e *Encbuf) PutByte(c byte)
- func (e *Encbuf) PutBytes(b []byte)
- func (e *Encbuf) PutHash(h hash.Hash)
- func (e *Encbuf) PutHashSum(h hash.Hash)
- func (e *Encbuf) PutString(s string)
- func (e *Encbuf) PutUvarint(x int)
- func (e *Encbuf) PutUvarint32(x uint32)
- func (e *Encbuf) PutUvarint64(x uint64)
- func (e *Encbuf) PutUvarintBytes(b []byte)
- func (e *Encbuf) PutUvarintStr(s string)
- func (e *Encbuf) PutVarint64(x int64)
- func (e *Encbuf) Reset()
- func (e *Encbuf) WriteToHash(h hash.Hash)
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidSize = errors.New("invalid size") ErrInvalidChecksum = errors.New("invalid checksum") )
Functions ¶
This section is empty.
Types ¶
type Decbuf ¶
Decbuf provides safe methods to extract data from a byte slice. It does all necessary bounds checking and advancing of the byte slice. Several datums can be extracted without checking for errors. However, before using any datum, the err() method must be checked.
func NewDecbufAt ¶
NewDecbufAt returns a new decoding buffer. It expects the first 4 bytes after offset to hold the big endian encoded content length, followed by the contents and the expected checksum.
func NewDecbufRaw ¶
NewDecbufRaw returns a new decoding buffer of the given length.
func NewDecbufUvarintAt ¶
NewDecbufUvarintAt returns a new decoding buffer. It expects the first bytes after offset to hold the uvarint-encoded buffers length, followed by the contents and the expected checksum.
func (*Decbuf) Be64Float64 ¶
func (*Decbuf) ConsumePadding ¶
func (d *Decbuf) ConsumePadding()
func (*Decbuf) UvarintBytes ¶
The return value becomes invalid if the byte slice goes away. Compared to UvarintStr, this avoid allocations.
func (*Decbuf) UvarintStr ¶
type Encbuf ¶
type Encbuf struct { B []byte C [binary.MaxVarintLen64]byte }
Encbuf is a helper type to populate a byte slice with various types.
func (*Encbuf) PutBE32int ¶
func (*Encbuf) PutBE64int64 ¶
func (*Encbuf) PutBEFloat64 ¶
func (*Encbuf) PutHashSum ¶
PutHashSum writes the Sum of the given hash to the buffer.
func (*Encbuf) PutUvarint ¶
func (*Encbuf) PutUvarint32 ¶
func (*Encbuf) PutUvarint64 ¶
func (*Encbuf) PutUvarintBytes ¶
PutUvarintBytes writes a variable length byte buffer.
func (*Encbuf) PutUvarintStr ¶
PutUvarintStr writes a string to the buffer prefixed by its varint length (in bytes!).
func (*Encbuf) PutVarint64 ¶
func (*Encbuf) WriteToHash ¶
WriteToHash writes the current buffer contents to the given hash.