publish_unix/
publish_unix.rs

1#[tokio::main]
2async fn main() -> Result<(), anyhow::Error> {
3    let client_type = simple_pub_sub::client::PubSubUnixClient {
4        path: "/tmp/simple.sock".to_string(),
5    };
6    // initialize the client.
7    let mut client = simple_pub_sub::client::Client::new(
8        simple_pub_sub::client::PubSubClient::Unix(client_type),
9    );
10
11    client.connect().await?;
12    // publish to the given topic.
13    client
14        .publish(
15            "abc".to_string(),
16            "test message".to_string().into_bytes().to_vec(),
17        )
18        .await
19}