Documentation ¶
Overview ¶
Package buffer contains helper functions for writing and reading basic types into and out of byte slices.
Index ¶
- Constants
- func LenByte() int
- func LenString(val string) int
- func LenUint16() int
- func LenUint32() int
- func LenUint64() int
- func LenUint8() int
- func ReadByte(buffer []byte, cursor *int) (byte, error)
- func ReadString(buffer []byte, cursor *int) (string, error)
- func ReadUint32(buffer []byte, cursor *int) (uint32, error)
- func ReadUint64(buffer []byte, cursor *int) (uint64, error)
- func WriteByte(val byte, buffer []byte, cursor *int)
- func WriteString(val string, buffer []byte, cursor *int)
- func WriteUint32(val uint32, buffer []byte, cursor *int)
- func WriteUint64(val uint64, buffer []byte, cursor *int)
Constants ¶
const ( BYTE_SIZE = 1 UINT8_SIZE = 1 UINT16_SIZE = 2 UINT32_SIZE = 4 UINT64_SIZE = 8 )
Data type sizes.
Variables ¶
This section is empty.
Functions ¶
func LenString ¶
LenString returns the encoded length of a given string, including the extra bytes required to encode its size.
func ReadByte ¶
ReadByte reads 1 byte value from the given buffer, starting at the given offset, and increments teh supplied cursor by the length of the encoded value.
func ReadString ¶
ReadString reads 1 string value from the given buffer, starting at the given offset, and increments teh supplied cursor by the length of the encoded value.
func ReadUint32 ¶
ReadUint32 reads 1 uint32 value from the given buffer, starting at the given offset, and increments teh supplied cursor by the length of the encoded value.
func ReadUint64 ¶
ReadUint64 reads 1 uint64 value from the given buffer, starting at the given offset, and increments teh supplied cursor by the length of the encoded value.
func WriteByte ¶
WriteByte writes the given byte value into a buffer at the given offset and increments the supplied cursor by the length of the encoded value.
func WriteString ¶
WriteString writes the given string value into a buffer starting at the given offset, and increments the supplied counter by the length of that encoded string.
func WriteUint32 ¶
WriteUint32 writes the given uint32 value into a buffer at the given offset and increments the supplied cursor by the lengh of the encoded value.
func WriteUint64 ¶
WriteUint64 writes the given uint64 value into a buffer at the given offset and increments teh supplied cursor by the length of the encoded value.
Types ¶
This section is empty.