From cabf790b909582e9c75cd5f4ff57e22b4d25fb23 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Fri, 25 Oct 2024 22:56:04 +0200 Subject: [PATCH] dbus: Implement ReadAll and AppendAll for VecDeque> --- dbus/src/arg/msgarg.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/dbus/src/arg/msgarg.rs b/dbus/src/arg/msgarg.rs index 92283f1c..6cac39b5 100644 --- a/dbus/src/arg/msgarg.rs +++ b/dbus/src/arg/msgarg.rs @@ -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> { + 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> { + fn read(ii: &mut Iter) -> Result { + 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,);