buffer

package
v0.0.0-...-915fa77 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package buffer contains helper functions for writing and reading basic types into and out of byte slices.

Index

Constants

View Source
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 LenByte

func LenByte() int

LenByte returns the encoded length of a byte value.

func LenString

func LenString(val string) int

LenString returns the encoded length of a given string, including the extra bytes required to encode its size.

func LenUint16

func LenUint16() int

LenUint16 returns the lengh of a uint32 value.

func LenUint32

func LenUint32() int

LenUint32 returns the lengh of a uint32 value.

func LenUint64

func LenUint64() int

LenUint64 returns the encoded length of a uint64 value.

func LenUint8

func LenUint8() int

LenUint8 returns the lengh of a uint32 value.

func ReadByte

func ReadByte(buffer []byte, cursor *int) (byte, error)

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

func ReadString(buffer []byte, cursor *int) (string, error)

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

func ReadUint32(buffer []byte, cursor *int) (uint32, error)

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

func ReadUint64(buffer []byte, cursor *int) (uint64, error)

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

func WriteByte(val byte, buffer []byte, cursor *int)

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

func WriteString(val string, buffer []byte, cursor *int)

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

func WriteUint32(val uint32, buffer []byte, cursor *int)

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

func WriteUint64(val uint64, buffer []byte, cursor *int)

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.

Jump to

Keyboard shortcuts

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