binary

package
v0.0.0-...-0659192 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Remaining = -1

Variables

This section is empty.

Functions

func MeasureVarInt

func MeasureVarInt(value int32) int

func ReadBool

func ReadBool(r io.Reader) (bool, error)

func ReadByte

func ReadByte(r io.Reader) (byte, error)

func ReadByteArray

func ReadByteArray(r io.Reader) ([]byte, error)

func ReadChatString

func ReadChatString(r io.Reader) (string, error)

func ReadCollection

func ReadCollection[T any](r io.Reader, read ReadFunc[T]) (values []T, err error)

func ReadEnum

func ReadEnum[T Enum](r io.Reader) (value T, err error)

func ReadLong

func ReadLong(r io.Reader) (int64, error)

func ReadOptional

func ReadOptional[T any](r io.Reader, read ReadFunc[T]) (*T, error)

func ReadOptionalFunc

func ReadOptionalFunc[T any](r io.Reader, read func(io.Reader) (T, error)) (*T, error)

func ReadRaw

func ReadRaw(r io.Reader, length int) ([]byte, error)

ReadRaw reads a raw byte array from the reader. The length may be Remaining to read whatever is present

func ReadRemaining

func ReadRemaining(r io.Reader) ([]byte, error)

func ReadSizedString

func ReadSizedString(r io.Reader, maxLength int) (string, error)

func ReadString

func ReadString(r io.Reader) (string, error)

func ReadTypedJSON

func ReadTypedJSON[T any](r io.Reader) (result T, err error)

func ReadUShort

func ReadUShort(r io.Reader) (uint16, error)

func ReadUUID

func ReadUUID(r io.Reader) (string, error)

func ReadVarInt

func ReadVarInt(r io.Reader) (int32, error)

func WriteBool

func WriteBool(w io.Writer, value bool) error

func WriteByte

func WriteByte(w io.Writer, value byte) error

func WriteByteArray

func WriteByteArray(w io.Writer, value []byte) error

func WriteChatString

func WriteChatString(w io.Writer, value string) error

func WriteCollection

func WriteCollection[T any](w io.Writer, values []T, write WriteFunc[T]) error

func WriteEnum

func WriteEnum[T Enum](w io.Writer, value T) error

func WriteLong

func WriteLong(w io.Writer, value int64) error

func WriteOptionalFunc

func WriteOptionalFunc[T any](w io.Writer, value *T, write func(io.Writer, T) error) error

func WriteRaw

func WriteRaw(w io.Writer, value []byte) error

func WriteSizedString

func WriteSizedString(w io.Writer, value string, maxLength int) error

func WriteString

func WriteString(w io.Writer, value string) error

func WriteTypedJSON

func WriteTypedJSON[T any](w io.Writer, value T) error

func WriteUShort

func WriteUShort(w io.Writer, value uint16) error

func WriteUUID

func WriteUUID(w io.Writer, value string) error

func WriteVarInt

func WriteVarInt(w io.Writer, v int32) error

Types

type Enum

type Enum interface {
	constraints.Integer
	Validate() bool
}

type ReadFunc

type ReadFunc[T any] func(*T, io.Reader) error

type WriteFunc

type WriteFunc[T any] func(*T, io.Writer) error

Jump to

Keyboard shortcuts

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