Client SDKsRustReference
RPC
Command, Query, response types, and request-response operations
Command
Outbound command request. The sender blocks until a subscriber responds or the timeout expires.
| Field | Type | Default | Description |
|---|---|---|---|
id | String | UUID v4 | Request identifier |
channel | String | required | Target channel name |
metadata | String | "" | Optional metadata |
body | Vec<u8> | [] | Command payload |
timeout | Duration | 5s | Maximum wait for response |
client_id | String | "" | Sender identity override |
tags | HashMap | {} | Key-value pairs |
Builder
use std::time::Duration;
let cmd = Command::builder()
.channel("device.reboot")
.body(b"device-42".to_vec())
.timeout(Duration::from_secs(10))
.build();CommandResponse
Returned by send_command.
| Field | Type | Description |
|---|---|---|
command_id | String | Original command request ID |
response_client_id | String | Identity of the handler |
executed | bool | Whether the command succeeded |
executed_at | i64 | Server timestamp |
error | String | Error message when executed is false |
tags | HashMap | Handler-attached tags |
CommandReceive / CommandReply
CommandReceive is delivered to the subscription callback. Use CommandReply::builder() to construct the response.
let reply = CommandReply::builder()
.request_id(&cmd.id)
.response_to(&cmd.response_to)
.build();
client.send_command_response(reply).await?;Query
Outbound query request with optional server-side caching.
| Field | Type | Default | Description |
|---|---|---|---|
id | String | UUID v4 | Request identifier |
channel | String | required | Target channel name |
metadata | String | "" | Optional metadata |
body | Vec<u8> | [] | Query payload |
timeout | Duration | 5s | Maximum wait for response |
cache_key | String | "" | Cache key (empty disables caching) |
cache_ttl | Duration | 0 | Cache time-to-live |
tags | HashMap | {} | Key-value pairs |
Builder
use std::time::Duration;
let query = Query::builder()
.channel("inventory.lookup")
.body(b"sku-12345".to_vec())
.timeout(Duration::from_secs(10))
.cache_key("sku-12345")
.cache_ttl(Duration::from_secs(60))
.build();QueryResponse
Returned by send_query.
| Field | Type | Description |
|---|---|---|
query_id | String | Original query request ID |
executed | bool | Whether the query succeeded |
metadata | String | Response metadata |
body | Vec<u8> | Response payload |
cache_hit | bool | Whether served from cache |
error | String | Error message when executed is false |
Client Methods
send_command / send_query
let resp = client.send_command(cmd).await?;
let resp = client.send_query(query).await?;subscribe_to_commands / subscribe_to_queries
let sub = client.subscribe_to_commands("channel", "", handler, None).await?;
let sub = client.subscribe_to_queries("channel", "", handler, None).await?;send_command_response / send_query_response
client.send_command_response(reply).await?;
client.send_query_response(reply).await?;Was this page helpful?