Hey,
I am trying to make use of this DBUS lib to interact with SystemD and grab the Object Path of the NetworkManager.service.
This is my code so far:
let c = Connection::get_private(BusType::System).unwrap();
let mut m = Message::new_method_call("org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"GetUnit")
.unwrap();
m.append_items(&["NetworkManager.service".into()]);
let r = c.send_with_reply_and_block(m, 2000).unwrap().get_items();
println!("{:?}", r);
which prints:
[ObjectPath(Path("/org/freedesktop/systemd1/unit/NetworkManager_2eservice"))]
I need the "/org/freedesktop/systemd1/unit/NetworkManager_2eservice"
part and as its an ObjectPath I thought this would work:
let c = Connection::get_private(BusType::System).unwrap();
let mut m = Message::new_method_call("org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"GetUnit")
.unwrap();
m.append_items(&["NetworkManager.service".into()]);
let r = c.send_with_reply_and_block(m, 2000).unwrap();
let p: ObjectPath<MethodType::Method, DataType::ObjectPath> = r.get1().unwrap();
println!("{:?}", p);
but it throws an error during compile:
error[E0223]: ambiguous associated type
--> src/service/mod.rs:65:23
|
65 | let p: ObjectPath<MethodType::Method, DataType::ObjectPath> = r.get1().unwrap();
| ^^^^^^^^^^^^^^^^^^ ambiguous associated type
|
= note: specify the type using the syntax `<Type as service::dbus::tree::MethodType>::Method`
error[E0223]: ambiguous associated type
--> src/service/mod.rs:65:43
|
65 | let p: ObjectPath<MethodType::Method, DataType::ObjectPath> = r.get1().unwrap();
| ^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
|
= note: specify the type using the syntax `<Type as service::dbus::tree::DataType>::ObjectPath`
error: aborting due to 2 previous errors
error: Could not compile `network_manager`.
I'm totally confused as to the correct way to get the object path out of the response, help!!!
Thanks in advance