client/
client.rs

1use linux_ipc::IpcChannel;
2use serde::{Deserialize, Serialize};
3use std::env;
4
5#[derive(Debug, Serialize, Deserialize)]
6struct Test {
7    pub name: String,
8    pub content: String,
9}
10
11fn main() {
12    let arg = &env::args().collect::<Vec<String>>()[1..].join(" ");
13    let mut channel = IpcChannel::connect("/tmp/example.sock").expect("Failed to create channel");
14
15    for _ in 0..2 {
16        let test = Test {
17            name: "test".to_string(),
18            content: arg.to_string(),
19        };
20
21        println!("Sending: {:#?}", test);
22
23        let response = channel.send::<_, Test>(test).expect("Failed to send message");
24
25        if let Some(response) = response {
26            println!("Received: {:#?}", response);
27        }
28    }
29}