View Source Kinda.CallbackRuntime (kinda v0.11.0)

Executes the BEAM side of a native callback and completes its reply token.

The native consumer supplies its own two-argument reply NIF. Callback functions return {:ok, value} or {:error, value} so domain adapters can retain their own state and diagnostics semantics while Kinda owns the common success/failure and exception boundary.

Summary

Types

callback_result(value)

@type callback_result(value) :: {:ok, value} | {:error, value}

outcome(value)

@type outcome(value) ::
  callback_result(value)
  | {:exception, :error | :exit | :throw, term(), Exception.stacktrace()}

Functions

invoke(reply_token, callback, reply, before_reply \\ fn _outcome -> :ok end)

@spec invoke(
  reply_token :: term(),
  callback :: (-> callback_result(value)),
  reply :: (term(), boolean() -> term()),
  before_reply :: (outcome(value) -> term())
) :: outcome(value)
when value: term()

invoke_reply(reply_token, callback, reply, before_reply \\ fn _outcome -> :ok end)

@spec invoke_reply(
  reply_token :: term(),
  callback :: (-> callback_result(value)),
  reply :: (term(), outcome(value) -> term()),
  before_reply :: (outcome(value) -> term())
) :: outcome(value)
when value: term()

Executes a callback and gives the complete normalized outcome to a consumer-defined reply function.

This is the projection boundary for callback ABIs whose return is richer than success/failure. A consumer may encode a scalar or enum result, or validate a resource and project its native handle, before completing the reply token.