DoubleDown.Contract.Dispatch.HandlerMeta.Stateful (double_down v0.58.0)

Copy Markdown View Source

Handler meta for a stateful (4/5-arity) function handler.

The :state field holds the mutable handler state directly — for raw set_stateful_handler this is user-provided state, for Double-managed handlers it is a CanonicalHandlerState struct.

Summary

Functions

Create a new Stateful handler meta. Validates that fun is a 4 or 5-arity function.

Replace the state within a Stateful handler meta.

Update the state within a Stateful handler meta via a function.

Types

t()

@type t() :: %DoubleDown.Contract.Dispatch.HandlerMeta.Stateful{
  fun: DoubleDown.Contract.Dispatch.Types.stateful_fun(),
  state: term()
}

Functions

new(fun, state)

Create a new Stateful handler meta. Validates that fun is a 4 or 5-arity function.

put_state(meta, new_state)

@spec put_state(t(), term()) :: t()

Replace the state within a Stateful handler meta.

update_state(meta, update_fn)

@spec update_state(t(), (term() -> term())) :: t()

Update the state within a Stateful handler meta via a function.