libero/rpc
Client-side RPC machinery.
call_by_name is the low-level entrypoint used by Libero-generated
stubs. It takes the WebSocket URL, the wire name, the args, and a
wrap callback that produces the Lustre message to dispatch when
the response arrives.
The JS FFI (rpc_ffi.mjs) auto-opens the WebSocket on first call and caches the connection. Calls issued before the socket is open are queued and flushed on the open event.
Type safety note: The response from the server is unsafe_coerced
from Dynamic to the expected return type. This is safe when the
client and server are built from the same source (the generator
guarantees the types match). However, deployment skew — where the
client is built against a newer or older server — can cause silent
type mismatches at runtime. Ensure client and server are deployed
together to avoid this.
Developers don’t usually call this module directly. They import the per-module stubs the Libero generator writes into their client package, and those stubs internally delegate here.
Values
pub fn call_by_name(
url url: String,
name name: String,
args args: args,
wrap wrap: fn(result) -> msg,
) -> effect.Effect(msg)
Invoke a server RPC by wire name, with typed args and a wrap callback. Called by generated stubs.
The url is read from a generated rpc_config module in the
consumer’s client package, not from this library, so each
consumer can configure their own WebSocket endpoint.