1use busrt::ipc::{Client, Config};
5use busrt::rpc::{Rpc, RpcClient};
6use busrt::{empty_payload, QoS};
7use serde::Deserialize;
8use std::collections::BTreeMap;
9
10#[derive(Deserialize)]
11struct Amount {
12 value: u64,
13}
14
15#[tokio::main]
16async fn main() -> Result<(), Box<dyn std::error::Error>> {
17 let name = "test.client.123";
18 let target = "test.client.rpc";
19 let config = Config::new("/tmp/busrt.sock", name);
21 let client = Client::connect(&config).await?;
22 let rpc = RpcClient::new0(client);
24 rpc.call0(target, "test", empty_payload!(), QoS::Processed)
26 .await?;
27 let mut payload: BTreeMap<&str, u32> = <_>::default();
28 payload.insert("value", 10);
29 rpc.call(
31 target,
32 "add",
33 rmp_serde::to_vec_named(&payload)?.into(),
34 QoS::Processed,
35 )
36 .await?;
37 let result = rpc
39 .call(target, "get", empty_payload!(), QoS::Processed)
40 .await?;
41 let amount: Amount = rmp_serde::from_slice(result.payload())?;
42 println!("{}", amount.value);
43 Ok(())
44}