3 releases (breaking)
0.3.0 | Oct 18, 2024 |
---|---|
0.2.0 | Oct 18, 2024 |
0.1.0 | Oct 17, 2024 |
#491 in Unix APIs
31 downloads per month
48KB
1K
SLoC
bussy
bussy is a simple interface on top of zbus. See the documentation for more details.
License
MIT OR Apache-2.0
lib.rs
:
bussy
bussy is a simple interface layered on top of the low-level zbus interfaces.
It provides the the following advantages:
- bussy is completely async but does not require you to use async/await. This allows you to use bussy in environments where using async code directly is not possible.
- All outgoing messages are sent in the order in which you call the respective functions. This applies even if the function returns a future and you don't await it immediately.
- bussy supports pipelining. All requests are sent immediately even if you do not await the response. This reduces the number of roundtrips for n method calls from n to 1.
- When you handle a method call, you get a [PendingReply] object that you can hold on to for as long as you want without blocking any other progress. You can then reply to the call whenever you are ready.
- All incoming messages are handled in a single thread in order. This means that, if you get a reply to a method call and receive a signal, the order in which your code is invoked is exactly the same as the order in which the peer sent these message. (Note that, if you are using async/await syntax for method calls, then tokio's scheduling of tasks might get in the way of this.)
Example
let zbus_conn = zbus::Connection::session().await.unwrap();
let conn_holder = bussy::Connection::wrap(&zbus_conn);
let conn = &conn_holder.connection;
let res = conn.call::<String>(
WellKnownName::from_static_str_unchecked("org.freedesktop.DBus"),
InterfaceName::from_static_str_unchecked("org.freedesktop.DBus"),
ObjectPath::from_static_str_unchecked("/org/freedesktop/DBus"),
MemberName::from_static_str_unchecked("GetNameOwner"),
&("org.freedesktop.DBus"), // the request body
).await;
println!("The name org.freedesktop.DBus is owned by {}", res.unwrap());
Dependencies
~9–20MB
~294K SLoC