Behaviour for renderer transport backends.
A transport handles the low-level I/O between the bridge and the renderer process: opening the connection, sending data, receiving incoming messages, and closing the connection.
Two implementations are provided:
Plushie.Transport.Porthandles:spawn(child process via Erlang Port) and:stdio(BEAM's own stdin/stdout) modes.Plushie.Transport.IOStreamhandles{:iostream, pid}mode for custom transports (SSH, TCP, WebSocket adapters).
Summary
Callbacks
Close the transport. Called during terminate.
Handle an incoming message that may belong to this transport.
Initialize the transport. Returns {:ok, state} on success.
Re-open the transport connection (e.g. after crash or dev rebuild).
Whether the transport supports restart (e.g. re-spawning the binary).
Send iodata to the renderer. Returns {:ok, state} on success.
Whether the transport is ready to accept outgoing data.
Types
@type t() :: struct()
Callbacks
@callback close(state :: t()) :: :ok
Close the transport. Called during terminate.
@callback handle_info(message :: term(), state :: t()) :: {:data, binary(), t()} | {:closed, term(), t()} | :ignore
Handle an incoming message that may belong to this transport.
Returns:
{:data, binary, state}when the message contains renderer data{:closed, reason, state}when the transport has closed:ignorewhen the message is not relevant to this transport
Initialize the transport. Returns {:ok, state} on success.
Called once during bridge init to open the connection.
Re-open the transport connection (e.g. after crash or dev rebuild).
Only meaningful for transports where restartable?/1 returns true.
Returns {:ok, new_state} or {:error, reason}.
Whether the transport supports restart (e.g. re-spawning the binary).
Only :spawn mode supports this. Stdio and iostream transports
cannot be restarted because they don't own the renderer lifecycle.
Send iodata to the renderer. Returns {:ok, state} on success.
Whether the transport is ready to accept outgoing data.