https://github.com/polymeilex/slimbus
Rust D-Bus crate on a diet
https://github.com/polymeilex/slimbus
Last synced: 4 months ago
JSON representation
Rust D-Bus crate on a diet
- Host: GitHub
- URL: https://github.com/polymeilex/slimbus
- Owner: PolyMeilex
- License: mit
- Created: 2024-02-15T03:52:21.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-04-28T01:18:28.000Z (about 1 year ago)
- Last Synced: 2025-10-19T12:55:35.612Z (8 months ago)
- Language: Rust
- Size: 172 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[zbus](https://github.com/dbus2/zbus/tree/main) but on a diet (2200 LOC)
This is basically stripped down alternative to zbus, it's only goal is to be as small as possible. No heavy deps, no async, no Windows support, no macOS support, no fancy abstractions, just a socket and message de/serialization.
Current dependency graph (hopefully it will get even smaller):
```
slimbus
├── enumflags2
├── log
├── rustix
├── serde
└── zvariant
```
```rs
fn main() -> Result<()> {
let (mut connection, mut reader) = Connection::session()?;
let msg = Message::method("/org/freedesktop/DBus", "Hello")?
.destination("org.freedesktop.DBus")?
.interface("org.freedesktop.DBus")?
.build(&())?;
let serial = msg.primary_header().serial_num();
let name = loop {
let msg = reader.read_socket()?;
println!("Got message: {:?}", msg);
if msg.header().reply_serial() == Some(serial) {
let body: OwnedUniqueName = msg.body().deserialize()?;
break body;
}
};
dbg!(name);
}
```