summaryrefslogtreecommitdiffstats
path: root/third_party/rust/dbus/examples/client.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/dbus/examples/client.rs')
-rw-r--r--third_party/rust/dbus/examples/client.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/third_party/rust/dbus/examples/client.rs b/third_party/rust/dbus/examples/client.rs
new file mode 100644
index 0000000000..a8707013ed
--- /dev/null
+++ b/third_party/rust/dbus/examples/client.rs
@@ -0,0 +1,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); }
+}
+