Rust D-Bus crate.
  • Rust 99.8%
  • Shell 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Reynard User 8ba0e25303
Some checks failed
Lint, Build and Test / zvariant_fuzz (push) Has been cancelled
Lint, Build and Test / doc_build (push) Has been cancelled
Lint, Build and Test / MSRV (push) Has been cancelled
Lint, Build and Test / fmt (push) Has been cancelled
Lint, Build and Test / clippy (push) Has been cancelled
Lint, Build and Test / semver-checks (push) Has been cancelled
CodSpeed Benchmarks / Run benchmarks (push) Has been cancelled
commitlint / commitlint (push) Has been cancelled
Lint, Build and Test / linux_test (push) Has been cancelled
Lint, Build and Test / windows_test (push) Has been cancelled
chore: sync dependencies (monorepo)
2026-04-07 18:06:23 +02:00
.githooks 🔨 add githook scripts 2024-05-13 08:00:49 -05:00
.github 👷 ci: adopt shared commitlint config for gimoji 2026-03-31 10:51:04 +11:00
book ✏️ book: Fix a typo 2026-01-09 17:36:02 +01:00
CI Drop now unneeded gitlab CI files 2023-05-11 23:37:35 +02:00
test-data zv: Test case for ostree data deserialization 2020-09-12 17:13:12 +02:00
zbus chore: sync dependencies (monorepo) 2026-04-07 18:06:23 +02:00
zbus_macros chore: sync dependencies (monorepo) 2026-04-07 18:06:23 +02:00
zbus_names chore: sync dependencies (monorepo) 2026-04-07 18:06:23 +02:00
zbus_xml chore: sync dependencies (monorepo) 2026-04-07 18:06:23 +02:00
zbus_xmlgen chore: sync dependencies (monorepo) 2026-04-07 18:06:23 +02:00
zvariant chore: sync dependencies (monorepo) 2026-04-07 18:06:23 +02:00
zvariant_derive chore: sync dependencies (monorepo) 2026-04-07 18:06:23 +02:00
zvariant_utils chore: sync dependencies (monorepo) 2026-04-07 18:06:23 +02:00
.codespellrc Ignore "ba" misspellings as this interferes with the percent-encoding lookup table / string 2022-06-08 22:24:31 +02:00
.commitlintrc.mjs 👷 ci: adopt shared commitlint config for gimoji 2026-03-31 10:51:04 +11:00
.editorconfig Extend .editorconfig for Markdown files 2021-01-02 15:55:36 +01:00
.gitignore 🚚 Commit Cargo.lock to git 2024-02-18 14:41:05 +01:00
.mailmap 📝 Add .mailmap 2026-01-22 16:32:13 +04:00
.rustfmt.toml 🎨 all: code comments should also adhere to 100 character limit 2023-06-27 17:39:01 +02:00
Cargo.lock ⬆️ micro: Update fastrand to v2.4.1 (#1758) 2026-04-07 01:03:54 +00:00
Cargo.toml chore: sync dependencies (monorepo) 2026-04-07 18:06:23 +02:00
CLAUDE.md ⬆️ cargo: Bump rust version to 1.87 2026-01-23 11:22:32 +01:00
CONTRIBUTING.md 📝 CONTRIBUTING: Better document the emoji tools 2025-12-20 18:01:14 +01:00
LICENSE Add a LICENSE file 2019-07-01 17:38:41 +02:00
LICENSE-MIT 📄 Add copyright line to the license file 2024-03-29 17:32:54 +01:00
logo.png 💄 Add the new version of our logo 2024-04-27 22:45:14 +02:00
README.md 🚚 Update name of Github space from dbus2 to z-galaxy 2025-10-14 18:10:07 +02:00
release-plz.toml 🤖 release-plz: 🚸 commits treated as additions 2026-02-22 14:07:23 +01:00
SECURITY.md 🚚 Update name of Github space from dbus2 to z-galaxy 2025-10-14 18:10:07 +02:00
zbus-pixels.gif README: pixelart illustration from Jakub Steiner 2021-11-14 21:08:11 +01:00

zbus illustration

zbus

CI Pipeline Status

A Rust API for D-Bus communication. The goal is to provide a safe and simple high- and low-level API akin to GDBus, that doesn't depend on C libraries.

The project is divided into the following subcrates:

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

We'll create a simple D-Bus service and client to demonstrate the usage of zbus. Note that these examples assume that a D-Bus broker is setup on your machine and you've a session bus running (DBUS_SESSION_BUS_ADDRESS environment variable must be set). This is guaranteed to be the case on a typical Linux desktop session.

Service

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

use std::{error::Error, future::pending};
use zbus::{connection, interface};

struct Greeter {
    count: u64
}

#[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 `tokio` here, you can use any async runtime of choice.
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let greeter = Greeter { count: 0 };
    let _conn = connection::Builder::session()?
        .name("org.zbus.MyGreeter")?
        .serve_at("/org/zbus/MyGreeter", greeter)?
        .build()
        .await?;

    // Do other things or go to wait forever
    pending::<()>().await;

    Ok(())
}

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

Client

Now let's write the client-side code for MyGreeter service:

use zbus::{Connection, Result, proxy};

#[proxy(
    interface = "org.zbus.MyGreeter1",
    default_service = "org.zbus.MyGreeter",
    default_path = "/org/zbus/MyGreeter"
)]
trait MyGreeter {
    async fn say_hello(&self, name: &str) -> Result<String>;
}

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

    // `proxy` macro creates `MyGreeterProxy` based on `Notifications` trait.
    let proxy = MyGreeterProxy::new(&connection).await?;
    let reply = proxy.say_hello("Maria").await?;
    println!("{reply}");

    Ok(())
}

Getting Help

If you need help in using these crates, are looking for ways to contribute, or just want to hang out with the cool kids, please come chat with us in the #zbus:matrix.org Matrix room. If something doesn't seem right, please file an issue.

Security

If you discover a security vulnerability, please report it privately following our Security Policy. We take security seriously and will respond promptly to reports.

Portability

Supported targets include Unix, Windows and macOS with Linux as the main target. Integration tests of zbus crate currently require a session bus running on the build host.

License

MIT license LICENSE-MIT

Alternative Crates

dbus-rs relies on the battle tested libdbus C library to send and receive messages. Companion crates add Tokio support, server builder without macros, and code generation.

There are many other D-Bus crates out there with various levels of maturity and features.