#D-Bus #DBus #IPC


Bindings to D-Bus, which is a bus commonly used on Linux for inter-process communication

37 releases

✓ Uses Rust 2018 edition

0.8.4 Jun 19, 2020
0.8.2 Mar 13, 2020
0.8.0 Dec 31, 2019
0.7.1 Sep 18, 2019
0.0.6 Mar 4, 2015

#2 in Unix APIs

Download history 5911/week @ 2020-03-16 7441/week @ 2020-03-23 5829/week @ 2020-03-30 5039/week @ 2020-04-06 4856/week @ 2020-04-13 5913/week @ 2020-04-20 5824/week @ 2020-04-27 6361/week @ 2020-05-04 6693/week @ 2020-05-11 6709/week @ 2020-05-18 7284/week @ 2020-05-25 11306/week @ 2020-06-01 11103/week @ 2020-06-08 10066/week @ 2020-06-15 8826/week @ 2020-06-22 8868/week @ 2020-06-29

30,732 downloads per month
Used in 117 crates (53 directly)



D-Bus bindings for Rust

crates.io API documentation license

The main dbus crate is fairly mature and the features you need should be all there. Breaking changes can still happen, but not often. If you're currently using 0.6.x of dbus and want to upgrade to later versions, you can read changes in dbus-rs 0.7.

  • Use blocking::Connection to connect to the session or system bus.
  • Use Message to send and receive messages. Get and append arguments of all types, see the argument guide for details.
  • Build method dispatching servers using the tree module. Standard D-Bus interfaces (introspection, properties, object manager) are supported.

If you have questions or comments that the documentation cannot answer in an easy way, filing an issue with your question is fine. Pull requests that improve the code, documentation, etc, are welcome!

Additional crates

  • dbus-tokio integrates D-Bus with Tokio. API documentation
  • dbus-codegen installs a binary tool which generates Rust code from D-Bus XML introspection data. The readme contains an introduction to how to use it.
  • libdbus-sys contains the raw FFI bindings to libdbus.



This example opens a connection to the session bus and asks for a list of all names currently present.

use dbus::blocking::Connection;
use std::time::Duration;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // First open up a connection to the session bus.
    let conn = Connection::new_session()?;

    // Second, create a wrapper struct around the connection that makes it easy
    // to send method calls to a specific destination and path.
    let proxy = conn.with_proxy("org.freedesktop.DBus", "/", Duration::from_millis(5000));

    // Now make the method call. The ListNames method call takes zero input parameters and
    // one output parameter which is an array of strings.
    // Therefore the input is a zero tuple "()", and the output is a single tuple "(names,)".
    let (names,): (Vec<String>,) = proxy.method_call("org.freedesktop.DBus", "ListNames", ())?;

    // Let's print all the names to stdout.
    for name in names { println!("{}", name); }


Examples of client code in the examples directory:


This example grabs the com.example.dbustest bus name, registers the /hello path and adds a method which returns a string. It then listens for incoming D-Bus events and handles them accordingly.

let c = Connection::new_session()?;
c.request_name("com.example.dbustest", false, true, false)?;
let f = Factory::new_fn::<()>();
let tree = f.tree(())
    .add(f.object_path("/hello", ()).introspectable()
        .add(f.interface("com.example.dbustest", ())
            .add_m(f.method("Hello", (), |m| {
                let n: &str = m.msg.read1()?;
                let s = format!("Hello {}!", n);
    ).add(f.object_path("/", ()).introspectable());
loop { c.process(Duration::from_millis(1000))?; }

Examples of server code in the examples directory:


The futures feature makes dbus depend on the futures crate. This enables the nonblock module (used by the dbus-tokio crate).

The no-string-validation feature skips an extra check that a specific string (e g a Path, ErrorName etc) conforms to the D-Bus specification, which might also make things a tiny bit faster. But - if you do so, and then actually send invalid strings to the D-Bus library, you might get a panic instead of a proper error.


Libdbus 1.6 or higher, and latest stable release of Rust. If you run Ubuntu (any maintained version should be okay), this means having the libdbus-1-dev and pkg-config packages installed while building, and the libdbus-1-3 package installed while running.

Cross compiling libdbus might be tricky because it binds to a C library, there are some notes here.


Apache 2.0 / MIT dual licensed. Any PR you make is assumed to have this license.