push

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package push provides low-level routines to encode values accordingly to the format of save files of Grim Dawn. The routines "push" encoded values to decoding/encoding context almost in terms of enqueuing of data, transforming the context in the process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Block

func Block(ctx *gdio.Decenc, kind uint32) func(func() bool)

Block takes a pointer to an instance of gdio.Decenc with kind of a block and returns an iterator, which wraps around the general processing of a block. The iterator properly pushes the block's prefix and suffix, yielding between and calculating the resulting block size. If the context has been halted or is halted during yield, the iterator returns immediately.

The function is supposed to be used in "for range" loop construction. It can panic, if the provided yield function is nil.

func Bool

func Bool(ctx *gdio.Decenc, v bool)

Bool takes a pointer to an instance of gdio.Decenc with a boolean value and pushes zero byte, if the value is false, or byte of one otherwise. Its behavior is based on Byte completely.

func Byte

func Byte(ctx *gdio.Decenc, v byte)

Byte takes a pointer to an instance of gdio.Decenc and a byte, encrypts the byte with help of the context's state and pushes the encrypted byte to the context's data stack, transforming the context's state in the process. It does nothing if the context has been halted.

func CheckInt

func CheckInt(ctx *gdio.Decenc, v int)

CheckInt takes a pointer to an instance of gdio.Decenc with an integer. It halts the context with an instance of ErrOutOfRange, if the value is not in the range [0, math.MaxUint32], otherwise it does nothing.

func Each

func Each[T any](ctx *gdio.Decenc, s []T, pushSize bool) iter.Seq[*T]

Each is a generic function to push elements of a slice to a context with the size of the slice or without it. It takes a pointer to an instance of gdio.Decenc, a slice of instances of T and a boolean flag of size's push. It returns an iterator function over pointers to the elements of the slice, which should be pushed to the context. The iterator pushes the slice's size to the context, if the provided flag is set. If the context has been halted, it stops the iteration.

The function is supposed to be used in "for range" loop construction. It can panic, if the provided yield function is nil.

func Float32

func Float32(ctx *gdio.Decenc, v float32)

Float32 takes a pointer to an instance of gdio.Decenc with a number in single-precision floating-point format and pushes the number to the context. Its behavior is based on Uint32 completely.

func Int

func Int(ctx *gdio.Decenc, v int)

Int takes a pointer to an instance of gdio.Decenc with an integer, checks, if the number is in proper range with CheckInt, and tries to push it with Uint32. Its behavior is defined by the functions completely.

func Slice

func Slice[T any](ctx *gdio.Decenc, v []T, p func(*gdio.Decenc, T))

Slice takes a pointer to an instance of gdio.Decenc, a slice of values of type T and a function p, which takes a context too with a value of type T. Slice pushes length of the slice to the context and then all the elements with help of p until the end of the slice or the context halts. It does nothing if the context has already been halted.

func State

func State(ctx *gdio.Decenc)

State takes a pointer to an instance of gdio.Decenc and pushes state of the context to the context as is without any transformation. It does nothing if the context has been halted.

func String

func String(ctx *gdio.Decenc, v string)

String takes a pointer to an instance of gdio.Decenc with a string value and pushes length of the string and its content to the context with help of Uint32 and Byte. It does nothing if the context has already been halted.

func StringUtf16

func StringUtf16(ctx *gdio.Decenc, v string)

StringUtf16 takes a pointer to an instance of gdio.Decenc with a string value and pushes length of the string and its content to the context with help of Each in format of UTF-16 little endian encoding. It does nothing if the context has already been halted.

func Uint32

func Uint32(ctx *gdio.Decenc, v uint32)

Uint32 takes a pointer to an instance of gdio.Decenc and an unsigned 32-bit integer, encrypts the number with help of the context's state and pushes the encrypted value to the context's data stack in little-endian order, transforming the context's state in the process. It does nothing if the context has been halted.

func Uuid

func Uuid(ctx *gdio.Decenc, u uuid.UUID)

Uuid takes a pointer to an instance of gdio.Decenc with a UUID and pushes the UUID bytes. Its behavior is based on Byte completely.

Types

type ErrOutOfRange

type ErrOutOfRange int

ErrOutOfRange represents errors, which signal, that an integer value is out of range [0, math.MaxUint32]

func (*ErrOutOfRange) Error

func (e *ErrOutOfRange) Error() string

Error returns a description of the error. It implements the corresponding method of the interface error.

func (*ErrOutOfRange) Value

func (e *ErrOutOfRange) Value() int

Value returns the value, which is out of the range

Jump to

Keyboard shortcuts

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