Crates.io | dbus-async |
lib.rs | dbus-async |
version | 2.3.1 |
source | src |
created_at | 2020-06-14 17:51:09.800365 |
updated_at | 2021-12-16 18:50:29.099326 |
description | Asynchronous DBus library |
homepage | |
repository | https://github.com/LinkTed/dbus-async |
max_upload_size | |
id | 253929 |
size | 104,870 |
A pure Rust written asynchronous DBus library.
Add this to your Cargo.toml
:
[dependencies]
dbus-async = "~2.3.1"
You have to specify, which Tokio Runtime should be used.
Cargo.toml
:
[dependencies.tokio]
version = " ~1.15.0"
features = ["rt-multi-thread"]
Cargo.toml
:
[dependencies.tokio]
version = "~1.15.0"
features = ["rt"]
use dbus_async::DBus;
use dbus_message_parser::Message;
use std::convert::TryInto;
#[tokio::main]
async fn main() {
let (dbus, _server_handle) = DBus::session(true)
.await
.expect("failed to get the DBus object");
// Create a MethodCall.
let msg = Message::method_call(
"org.freedesktop.DBus".try_into().unwrap(),
"/org/freedesktop/DBus".try_into().unwrap(),
"org.freedesktop.DBus.Peer".try_into().unwrap(),
"Ping".try_into().unwrap(),
);
// Send the message and get the return message.
let return_msg = dbus.call(msg).await;
// Print the return message.
println!("{:?}", return_msg);
}
If you want to implement a DBus service and do not implement the dbus_async::Handler
trait
manually then use dbus-async-derive
crate.