dbus-async 1.1.0

Asynchronous DBus library
Documentation
use dbus_async::DBus;
use dbus_message_parser::Message;
use futures::channel::mpsc::channel;
use futures::stream::StreamExt;

// This is a low level example, where the user create the channel to receive the message.

#[tokio::main]
async fn main() {
    let (dbus, _connection_handle) = DBus::session(true)
        .await
        .expect("failed to get the DBus object");

    // Initialize the object path.
    let object_path = "object/path/test".to_string();

    // Create a FIFO with a size of 1024
    let (sender, mut receiver) = channel::<Message>(1024);

    // Register the object path
    if let Err(e) = dbus.add_object_path(object_path, sender) {
        panic!("Cannot add path: {:?}", e);
    }

    // Get the next message for the object path "/object/path/test"
    while let Some(msg) = receiver.next().await {
        println!("{:?}", msg);
    }
}