encoding

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBufferNotLargeEnough is returned when the buffer is not large enough to read the requested data
	ErrBufferNotLargeEnough = errors.New("buffer not large enough")
)

Functions

func Float32

func Float32(buf []byte) float32

func Float64

func Float64(buf []byte) float64

func Int16

func Int16(buf []byte) int16

func Int32

func Int32(buf []byte) int32

func Int64

func Int64(buf []byte) int64

func Int8

func Int8(buf byte) int8

func Read4Times

func Read4Times[T any](f func() T) [4]T

Read4Times reads a value from a function 4 times and returns an array of the values

func Read8Times

func Read8Times[T any](f func() T) [8]T

Read8Times reads a value from a function 8 times and returns an array of the values

func Uint16

func Uint16(buf []byte) uint16

func Uint32

func Uint32(buf []byte) uint32

func Uint64

func Uint64(buf []byte) uint64

func Uint8

func Uint8(buf byte) uint8

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(buffer []byte) *Decoder

func (*Decoder) Byte

func (d *Decoder) Byte() byte

Uint8 reads a byte from the buffer, and moves the index by 1

func (*Decoder) Float32

func (d *Decoder) Float32() float32

Float32 reads a float32 from the buffer, and moves the index by 4

func (*Decoder) Float64

func (d *Decoder) Float64() float64

Float64 reads a float64 from the buffer, and moves the index by 8

func (*Decoder) Index

func (d *Decoder) Index() int

Index returns the current index of the decoder

func (*Decoder) Int16

func (d *Decoder) Int16() int16

Int16 reads a uint16 from the buffer, and moves the index by 2

func (*Decoder) Int32

func (d *Decoder) Int32() int32

Int32 reads a uint32 from the buffer, and moves the index by 4

func (*Decoder) Int64

func (d *Decoder) Int64() int64

Int64 reads a uint64 from the buffer, and moves the index by 8

func (*Decoder) Int8

func (d *Decoder) Int8() int8

Int8 reads a uint8 from the buffer, and moves the index by 1

func (*Decoder) LeftToRead

func (d *Decoder) LeftToRead() int

LeftToRead returns the amount of bytes left to read

func (*Decoder) Len

func (d *Decoder) Len() int

Len returns the length of the buffer

func (*Decoder) Read

func (d *Decoder) Read(p []byte) int

Read reads the buffer into the given byte slice

func (*Decoder) Read48

func (d *Decoder) Read48() [48]byte

func (*Decoder) Seek

func (d *Decoder) Seek(offset int)

Seek sets the index of the decoder

func (*Decoder) Skip

func (d *Decoder) Skip(offset int)

Skip moves the index of the decoder by the offset

func (*Decoder) Uint16

func (d *Decoder) Uint16() uint16

Uint16 reads a uint16 from the buffer, and moves the index by 2

func (*Decoder) Uint32

func (d *Decoder) Uint32() uint32

Uint32 reads a uint32 from the buffer, and moves the index by 4

func (*Decoder) Uint64

func (d *Decoder) Uint64() uint64

Uint64 reads a uint64 from the buffer, and moves the index by 8

func (*Decoder) Uint8

func (d *Decoder) Uint8() uint8

Uint8 reads a uint8 from the buffer, and moves the index by 1

Jump to

Keyboard shortcuts

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