subscribe_unix/
subscribe_unix.rs1use tokio::select;
2
3#[tokio::main]
4async fn main() -> Result<(), anyhow::Error> {
5 let client_type = simple_pub_sub::client::PubSubUnixClient {
6 path: "/tmp/simple.sock".to_string(),
7 };
8 let mut client = simple_pub_sub::client::Client::new(
10 simple_pub_sub::client::PubSubClient::Unix(client_type),
11 );
12
13 client.connect().await?;
15 client.subscribe("abc".to_string()).await?;
17
18 loop {
19 select! {
20 msg = client.read_message()=>{
21 match msg{
22 Ok(msg)=>{
23 println!("{}:{:?}", msg.topic, msg.message);
24 }
25 Err(e)=>{
26 println!("Error: {:?}", e);
27 }
28 }
29 }
30 }
31 }
32}