summaryrefslogtreecommitdiffstats
path: root/third_party/rust/dbus/examples/client.rs
blob: a8707013ed0deca56824f57c46f43e2316c56461 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
extern crate dbus;

use dbus::{Connection, BusType, Message};
use dbus::arg::Array;

fn main() {
    let c = Connection::get_private(BusType::Session).unwrap();
    let m = Message::new_method_call("org.freedesktop.DBus", "/", "org.freedesktop.DBus", "ListNames").unwrap();
    let r = c.send_with_reply_and_block(m, 2000).unwrap();
    // ListNames returns one argument, which is an array of strings.
    let arr: Array<&str, _>  = r.get1().unwrap();
    for name in arr { println!("{}", name); }
}