Issue when returning a struct from an interface method
Consider this example program:
use serde::{Deserialize, Serialize};
use zbus::{blocking::Connection, dbus_interface};
use zvariant::derive::Type;
#[derive(Deserialize, Serialize, Type)]
struct MyStruct {
value1: String,
value2: String,
}
struct MyIface;
#[dbus_interface(name = "org.zbus.MyIface")]
impl MyIface {
fn get_struct(&self) -> MyStruct {
MyStruct {
value1: "One".into(),
value2: "Two".into()
}
}
}
fn main() {
let conn = Connection::session().unwrap();
conn.request_name("org.zbus.Test").unwrap();
conn.object_server_mut().at("/org/zbus/test", MyIface).unwrap();
loop {}
}
Calling this server like so:
busctl --user call org.zbus.Test /org/zbus/test org.zbus.MyIface GetStruct
Results in this reply:
ss "One" "Two"
Which I think is a bug. Here is the introspection data:
busctl --user introspect org.zbus.Test /org/zbus/test org.zbus.MyIface
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.GetStruct method - (ss) -
A struct should clearly be returned. To achieve proper behavior, I have to modify the method like this:
fn get_struct(&self) -> (MyStruct,) {
(MyStruct {
value1: "One".into(),
value2: "Two".into()
},)
}
Which is ugly and shouldn't be necessary according to the documentation.