31 releases (stable)

2.3.2 Jun 18, 2022
2.2.0 May 1, 2022
2.1.1 Feb 3, 2022
2.0.0-beta.8 Dec 27, 2021
0.1.2 Jul 7, 2020

#6 in Unix APIs

Download history 22622/week @ 2022-03-11 30661/week @ 2022-03-18 28586/week @ 2022-03-25 27799/week @ 2022-04-01 28577/week @ 2022-04-08 24292/week @ 2022-04-15 27362/week @ 2022-04-22 29137/week @ 2022-04-29 27546/week @ 2022-05-06 22634/week @ 2022-05-13 24067/week @ 2022-05-20 21934/week @ 2022-05-27 24703/week @ 2022-06-03 27018/week @ 2022-06-10 26433/week @ 2022-06-17 22584/week @ 2022-06-24

104,780 downloads per month
Used in 92 crates (36 directly)

MIT license

19K SLoC


This is the main subcrate of the zbus project, that provides the API to interact with D-Bus. 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.

Status: Stable.

Getting Started

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.

Example code


This code display a notification on your Freedesktop.org-compatible OS:

use std::{collections::HashMap, error::Error};

use zbus::{Connection, dbus_proxy};
use zvariant::Value;

    interface = "org.freedesktop.Notifications",
    default_service = "org.freedesktop.Notifications",
    default_path = "/org/freedesktop/Notifications"
trait Notifications {
    fn notify(
        app_name: &str,
        replaces_id: u32,
        app_icon: &str,
        summary: &str,
        body: &str,
        actions: &[&str],
        hints: &HashMap<&str, &Value<'_>>,
        expire_timeout: i32,
    ) -> zbus::Result<u32>;

// Although we use `async-std` here, you can use any async runtime of choice.
async fn main() -> Result<(), Box<dyn Error>> {
    let connection = Connection::session().await?;

    // `dbus_proxy` macro creates `NotificationProxy` based on `Notifications` trait.
    let proxy = NotificationsProxy::new(&connection).await?;
    let reply = proxy.notify(
        "A summary",
        "Some body",



A simple service that politely greets whoever calls its SayHello method:

use std::{error::Error, future::pending};
use zbus::{ConnectionBuilder, dbus_interface};

struct Greeter {
    count: u64

#[dbus_interface(name = "org.zbus.MyGreeter1")]
impl Greeter {
    // Can be `async` as well.
    fn say_hello(&mut self, name: &str) -> String {
        self.count += 1;
        format!("Hello {}! I have been called {} times.", name, self.count)

// Although we use `async-std` here, you can use any async runtime of choice.
async fn main() -> Result<(), Box<dyn Error>> {
    let greeter = Greeter { count: 0 };
    let _ = ConnectionBuilder::session()?
        .serve_at("/org/zbus/MyGreeter", greeter)?

    // Do other things or go to wait forever


You can use the following command to test it:

$ busctl --user call org.zbus.MyGreeter /org/zbus/MyGreeter org.zbus.MyGreeter1 SayHello s "Maria"
s "Hello Maria! I have been called 1 times."

Blocking API

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:

Moreover, by default zbus makes use of async-io for all I/O, which also launches its own thread to run its own internal executor.

Special tokio support

Since tokio is the most popular async runtime, zbus provides an easy way to enable tight integration with it without you having to worry about any of the above: Enabling the tokio feature and disabling the default async-io feature:

# Sample Cargo.toml snippet.
zbus = { version = "2", default-features = false, features = ["tokio"] }

That's it! No threads launched behind your back by zbus (directly or indirectly) now and no need to tick any executors etc. 😼

Note: On Windows, the async-io feature is currently required for UNIX domain socket support, see the corresponding tokio issue on GitHub.


~249K SLoC