Rust D-Bus crate.
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:
zbus: The main subcrate. It provides the API to interact with D-Bus, the D-Bus wire
format (what used to be the zvariant crate) and the bus name types (what used to be
the zbus_names crate). With default-features = false you get the wire format and the name
types alone, without any of the D-Bus API.zbus_macros: The procedural macros behind #[proxy], #[interface], #[derive(DBusError)]
and the wire-format derives. zbus re-exports all of them, so you rarely depend on it directly.zbus_xml: API to handle D-Bus introspection description XML.zbus_xmlgen: A developer tool to generate Rust code from D-Bus interface description XML.zbus_utils: The D-Bus signature parser, name validators and derive-macro plumbing
shared by zbus and zbus_macros.zgvariant is a sibling project. It implements GVariant, the format zbus itself dropped in
6.0. From its 2.0 release it builds on zbus_utils too, so its signature type is the same one
zbus uses; zgvariant 1.x depends on zvariant_utils 4.x — this crate under its old name — and its
signature type is a distinct one.
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.
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.
A simple service that politely greets whoever calls its SayHello method:
…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."Now let's write the client-side code for MyGreeter service:
…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.
If you discover a security vulnerability, please report it privately following our Security Policy. We take security seriously and will respond promptly to reports.
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.
MIT license LICENSE-MIT
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.
No open issues yet, or sync has not completed.