ybus
Pure-Nim DBus implementation
Summary
| Latest Version | 0.1.1 |
|---|---|
| License | BSD-3-Clause |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-09-04 07:26 |
Tags
Authors
- xTrayambak
Installation
nimble install ybus
choosenim install ybus
git clone https://github.com/nim-windowing/ybus
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| ybus | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 2.2.0 | No |
| shakar >= | 0.1.3 | No |
| flatty >= | 0.3.4 | No |
| results >= | 0.5.1 | No |
| pretty >= | 0.2.0 | No |
Source
| Repository | https://github.com/nim-windowing/ybus |
|---|---|
| Homepage | https://github.com/nim-windowing/ybus |
| Registry Source | nimble_official |
README
ybus
ybus is an implementation of the D-Bus protocol in pure Nim. It is currently not suitable for real-world usage, but it's slowly getting there.
As expected, it relies on no external non-Nim dependencies.
roadmap
- [X] System bus socket resolution
- [X] Authentication machine
- [X] Basic sync client with handshake
- [X] Call methods on the bus
- [ ] Programmer-friendly API to create interfaces and services on the bus
- [X] Writer: Support for emitting all remaining header types
- [ ] Writer: Support for emitting variants besides strings and object paths
- [ ] Reader: Support for parsing some remaining header types
- [ ] Reader: Support for parsing all remaining variant types
- [X] Tool to convert protocol XML files to Nim wrappers
- [ ] UNIX file descriptors support (for sharing of a FD between services)
- [ ]
asyncdispatchandchronosbased asynchronous clients - [ ] Benchmarking ybus against implementations in other languages (
zbusfor Rust,godbusfor Go, etc.) - [ ] More error-proofing (Possibly fuzzing the reader and variant parser? They don't use any pointer math so this will only catch logic bugs and OOB reads that'd cause defects)
distant / low-priority goals
- [ ] Proper, tested big endian support
- [ ] Abstract keys in system bus socket resolution. Most systems do not use this.
basic example
ybus' core (wire protocol reader and writer) is mostly written as pure, side-effect-free functions. The unix_sync client, as the name suggests, is a synchronous D-Bus client that uses UNIX sockets.
Here is a basic example which connects to the system bus and queries the version of systemd running on the machine.
import std/options
import pkg/ybus/client/unix_sync
let client = newBusClient()
client.connect()
debugEcho "serial: " & $client.serial
debugEcho "unique name: " & client.uniqueName
let resp = client.call(
path = "/org/freedesktop/systemd1",
iface = "org.freedesktop.DBus.Properties",
destination = "org.freedesktop.systemd1",
member = "Get",
arguments =
@[
Variant(kind: VariantKind.String, str: "org.freedesktop.systemd1.Manager"),
Variant(kind: VariantKind.String, str: "Version"),
],
signature = "ss",
)
echo "systemd version " & resp.get().body[0].str