Skip to content

Commit

Permalink
dbus: Implement ReadAll and AppendAll for VecDeque<Box<RefArg>>
Browse files Browse the repository at this point in the history
  • Loading branch information
diwic committed Oct 25, 2024
1 parent 9786245 commit cabf790
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions dbus/src/arg/msgarg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,33 @@ impl ReadAll for () {
}
}


/// This is a fallback for methods that have tons of arguments.
/// Usually we'll use a tuple because it is more ergonomic, but AppendAll is only
/// implemented for tuples up to a certain size.
impl AppendAll for VecDeque<Box<dyn RefArg>> {
fn append(&self, ia: &mut IterAppend) {
for arg in self {
arg.append(ia);
}
}
}

/// This is a fallback for methods that have tons of arguments.
/// Usually we'll use a tuple because it is more ergonomic, but ReadAll is only
/// implemented for tuples up to a certain size.
impl ReadAll for VecDeque<Box<dyn RefArg>> {
fn read(ii: &mut Iter) -> Result<Self, TypeMismatchError> {
let mut r = VecDeque::new();
while let Some(arg) = ii.get_refarg() {
r.push_back(arg);
ii.next();
}
Ok(r)
}
}


argall_impl!(a A str,);
argall_impl!(a A str, b B str,);
argall_impl!(a A str, b B str, c C str,);
Expand Down

0 comments on commit cabf790

Please sign in to comment.