A D-Bus binding for rust.
Current state: Slowly maturing. Most stuff you need should be working:
- Connect to system or session bus
- Messages send/receive (method calls, method returns, signals, errors)
- Message get/append arguments (through either generics or enums), all types (including Unix Fd).
- Build server side trees, with introspection and method dispatch (boxed closures)
- Properties, on both client and server sides (set/get/getall methods, signals on server side)
- Optional async API (for poll-based mainloops, e g mio)
Examples
Client
This example opens a connection to the session bus and asks for a list of all names currently present.
let c = get_private.unwrap;
let m = new_method_call.unwrap;
let r = c.send_with_reply_and_block.unwrap;
let arr: = r.get1.unwrap;
for name in arr
You can try a similar example by running:
cargo run --example client
Server
This example grabs the com.example.dbustest bus name, registers the /hello path and adds a method which returns a string. It then listens for incoming D-Bus events and handles them accordingly.
let c = get_private.unwrap;
c.register_name.unwrap;
let f = new_fn;
let tree = f.tree.add;
tree.set_registered.unwrap;
for _ in tree.run
You can try a similar example by running:
cargo run --example server
Properties
This example gets the current version of the Policykit backend.
let c = get_private.unwrap;
let p = new;
let v = p.get.unwrap;
You can try a this example by running:
cargo run --example properties
For an extended example, which also uses non-panicing error handling, see
examples/rtkit.rs
License
Apache / MIT dual licensed.