This crate provides the main API you will use to interact with D-Bus from Rust. It takes care of the establishment of a connection, the creation, sending and receiving of different kind of D-Bus messages (method calls, signals etc) for you.
zbus crate is currently Linux-specific[^otheros].
The best way to get started with zbus is the book, where we start with basic D-Bus concepts and explain with code samples, how zbus makes D-Bus easy.
This code display a notification on your Freedesktop.org-compatible OS:
use ; use ; use Value; // Although we use `async-std` here, you can use any async runtime of choice. async
A simple service that politely greets whoever calls its
use ; use ; // Although we use `async-std` here, you can use any async runtime of choice. async
You can use the following command to test it:
While zbus is primarily asynchronous (since 2.0), blocking wrappers are provided for convenience.
Compatibility with async runtimes
zbus is runtime-agnostic and should work out of the box with different Rust async runtimes. However, in order to achieve that, zbus spawns a thread per connection to handle various internal tasks. If that is something you would like to avoid, you need to:
- Use [
ConnectionBuilder] and disable the
- Ensure the internal executor keeps ticking continuously.