-
I want to return a vec of items with crossroads, here's my code: let mut cr = Crossroads::new();
let iface_token = cr.register(
"name",
|b: &mut IfaceBuilder<()>| {
b.method("read", (), ("logs",), move |ctx, _, ()| {
Ok(vec![(3_u32, 4_i64, 5_u8)])
});
},
); This doesn't compile because of:
how can I return multiple values inside of a method? Should I open a PR that implements |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'm really not sure, if this is the right way, but it works? :) struct MyVec<T>(Vec<T>);
impl<T> ArgAll for MyVec<T>
where
T: Arg,
{
type strs = (&'static str,);
fn strs_sig<F: FnMut(&'static str, dbus::Signature<'static>)>(a: Self::strs, mut f: F) {
f(a.0, Signature::make::<Vec<T>>());
}
}
impl<T> AppendAll for MyVec<T>
where
T: Arg + Append,
{
fn append(&self, ia: &mut dbus::arg::IterAppend) {
ia.append(Array::new(&self.0));
}
} Still waiting for a proper answer though |
Beta Was this translation helpful? Give feedback.
-
Okay, my bad, but this is somewhat inconvenient... The correct solution would be: Ok((vec![(3_u32, 4_i64, 5_u8)],)) so a 1 sized tuple instead of the vec directly. Is there a reason for this, or just a technical decision? |
Beta Was this translation helpful? Give feedback.
Okay, my bad, but this is somewhat inconvenient...
The correct solution would be:
so a 1 sized tuple instead of the vec directly. Is there a reason for this, or just a technical decision?