Expand description
§Discover
A built-in RPC request/response pair for client discovery and health checking over IPC.
§Purpose
The discover module provides a simple “ping” mechanism that allows one IPC endpoint to check whether another endpoint is alive and reachable. The responding endpoint includes its version string, which can be used for compatibility checks.
§Types
DiscoverRequest: An empty RPC request that acts as a ping. ImplementsRpcRequestwithNAME = "DiscoverRequest".DiscoverResponse: Contains aversionstring identifying the responding client.DiscoverHandler: A pre-builtRpcHandlerthat responds toDiscoverRequestwith a fixedDiscoverResponse. Register it on anIpcClientto make that client discoverable.
§Usage
§Responding to discover requests
Register the handler so the client responds to incoming discover requests:
let handler = DiscoverHandler::new(DiscoverResponse {
version: "1.0.0".to_string(),
});
ipc_client.register_rpc_handler(handler).await;§Sending a discover request
Send a discover request to a specific endpoint:
let response = ipc_client
.request::<DiscoverRequest>(
DiscoverRequest,
destination_endpoint,
None, // optional cancellation token
)
.await?;
println!("Remote version: {}", response.version);§WASM
In WASM contexts, two functions are exported:
ipcRegisterDiscoverHandler(client, response): registers the handleripcRequestDiscover(client, destination, abortSignal?): sends a discover request
Structs§
- Discover
Handler - A simple handler for the
DiscoverRequestthat always returns the same response. Used to enable discovery/ping functionality and provide version information. - Discover
Request - A request to discover/ping a client.
- Discover
Response - The response to a discover/ping request.