// define the on_message function (callback). pub fn on_msg(topic: String, message: Vec) { println!("topic: {} message: {:?}", topic, message) } #[tokio::main] async fn main() -> Result<(), String> { let client_type = simple_pub_sub::client::PubSubUnixClient { path: "/tmp/simple.sock".to_string(), }; // initialize the client. let mut client = simple_pub_sub::client::Client::new( simple_pub_sub::client::PubSubClient::Unix(client_type), ); // set the callback function. client.on_message(on_msg); // connect the client. let _ = client.connect().await; // subscribe to the given topic. let _ = client.subscribe("abc".to_string()).await; Ok(()) }