Skip to content

Commit

Permalink
✨ zm: Use SerializeTuple in proxy calls
Browse files Browse the repository at this point in the history
This allows using types that only implement DynamicType in
macro-generated proxy functions.
  • Loading branch information
danieldg committed Jan 27, 2024
1 parent 1ac5911 commit 5696d5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions zbus_macros/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ fn gen_proxy_method_call(
let object_path: #zbus::zvariant::OwnedObjectPath =
self.0.call(
#method_name,
&(#(#args),*),
&#zbus::zvariant::DynamicTuple((#(#args,)*)),
)
#wait?;
#proxy_path::builder(&self.0.connection())
Expand All @@ -574,11 +574,11 @@ fn gen_proxy_method_call(
// the '()' from the signature that we add and not the actual intended ones.
let arg = &args[0];
quote! {
&(#arg,)
&#zbus::zvariant::DynamicTuple((#arg,))
}
} else {
quote! {
&(#(#args),*)
&#zbus::zvariant::DynamicTuple((#(#args),*))
}
};

Expand Down
11 changes: 10 additions & 1 deletion zbus_macros/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ mod param {
}

mod test {
use zbus::fdo;
use zbus::{
fdo,
zvariant::{OwnedStructure, Structure},
};

#[zbus_macros::dbus_proxy(
assume_defaults = false,
Expand All @@ -34,6 +37,12 @@ mod test {
/// which is useful to pass in a proxy as a param. It serializes it as an `ObjectPath`.
fn some_method<T>(&self, object_path: &T) -> zbus::Result<()>;

/// A call accepting an argument that only implements DynamicType and Serialize.
fn test_dyn_type(&self, arg: Structure<'_>, arg2: u32) -> zbus::Result<()>;

/// A call returning an type that only implements DynamicDeserialize
fn test_dyn_ret(&self) -> zbus::Result<OwnedStructure>;

#[dbus_proxy(name = "CheckRENAMING")]
fn check_renaming(&self) -> zbus::Result<Vec<u8>>;

Expand Down

0 comments on commit 5696d5f

Please sign in to comment.