Guppy.Native behaviour (guppy v0.1.0)

Copy Markdown View Source

Behaviour for the native GPUI bridge.

The default production direction is an in-VM NIF, following wx's overall integration model while keeping Guppy's own API and render architecture.

Summary

Types

command()

@type command() :: term()

response()

@type response() :: {:ok, term()} | {:error, term()}

Callbacks

cast(server, command)

@callback cast(GenServer.server(), command()) :: :ok

connected?(server)

@callback connected?(GenServer.server()) :: boolean()

request(server, command, timeout)

@callback request(GenServer.server(), command(), timeout()) :: response()

Performs a native request.

Implementations own timeout enforcement: request/3 must return within the given timeout (returning {:error, :native_timeout} when the underlying work cannot complete in time) rather than blocking the caller indefinitely. The NIF implementation bounds every request with a deadline-aware wait.