zbus 1.1.1

API for D-Bus communication

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].

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;
use std::error::Error;

use zbus::dbus_proxy;
use zvariant::Value;

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>;

fn main() -> Result<(), Box<dyn Error>> {
let connection = zbus::Connection::new_session()?;

let proxy = NotificationsProxy::new(&connection)?;
let reply = proxy.notify(
"A summary",
"Some body",



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

use std::error::Error;
use std::convert::TryInto;
use zbus::{dbus_interface, fdo};

struct Greeter;

#[dbus_interface(name = "org.zbus.MyGreeter1")]
impl Greeter {
fn say_hello(&self, name: &str) -> String {
format!("Hello {}!", name)

fn main() -> Result<(), Box<dyn Error>> {
let connection = zbus::Connection::new_session()?;

let mut object_server = zbus::ObjectServer::new(&connection);
object_server.at(&"/org/zbus/MyGreeter".try_into()?, Greeter)?;
loop {
if let Err(err) = object_server.try_handle_next() {
eprintln!("{}", err);

You can use the following command to test it:

$ busctl --user call \
org.zbus.MyGreeter \
/org/zbus/MyGreeter \
org.zbus.MyGreeter1 \
SayHello s "Maria"
Hello Maria!

[^otheros]: Support for other OS exist, but it is not supported to the same extent. D-Bus clients in javascript (running from any browser) do exist though. And zbus may also be working from the browser sometime in the future too, thanks to Rust 🦀 and WebAssembly 🕸.