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) Be64int64() int64
- func (d *Decbuf) Byte() byte
- 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) Uvarint() int
- func (d *Decbuf) Uvarint64() uint64
- 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) PutByte(c byte)
- func (e *Encbuf) PutHash(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) PutUvarintStr(s string)
- func (e *Encbuf) PutVarint64(x int64)
- func (e *Encbuf) Reset()
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 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) 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) PutUvarint ¶
func (*Encbuf) PutUvarint32 ¶
func (*Encbuf) PutUvarint64 ¶
func (*Encbuf) PutUvarintStr ¶
PutUvarintStr writes a string to the buffer prefixed by its varint length (in bytes!).