From 3af251c87144a2bcfffd330c1b6e4e2a137a8df8 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Wed, 17 Jan 2024 14:03:13 -0700 Subject: [PATCH] Remove dbus_ prefix for proc macros Rename all attribute macros to zbus --- README.md | 10 +- book/src/blocking.md | 40 +- book/src/client.md | 64 +- book/src/faq.md | 16 +- book/src/server.md | 36 +- zbus/README.md | 10 +- zbus/examples/watch-systemd-jobs.rs | 6 +- zbus/src/blocking/fdo.rs | 3 +- zbus/src/blocking/mod.rs | 2 +- zbus/src/blocking/object_server.rs | 18 +- zbus/src/blocking/proxy/mod.rs | 4 +- zbus/src/connection/mod.rs | 10 +- zbus/src/fdo.rs | 90 +- zbus/src/lib.rs | 58 +- zbus/src/object_server/mod.rs | 22 +- zbus/src/object_server/signal_context.rs | 2 +- zbus/src/proxy/mod.rs | 15 +- zbus/tests/e2e.rs | 111 +- zbus_macros/iface.txt | 6061 ++++++++++++++++++++++ zbus_macros/src/error.rs | 72 +- zbus_macros/src/iface.rs | 159 +- zbus_macros/src/lib.rs | 78 +- zbus_macros/src/proxy.rs | 188 +- zbus_macros/tests/tests.rs | 52 +- zvariant_utils/src/macros.rs | 65 + 25 files changed, 6818 insertions(+), 374 deletions(-) create mode 100644 zbus_macros/iface.txt diff --git a/README.md b/README.md index f1508654d..9cf17e3d6 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,13 @@ A simple service that politely greets whoever calls its `SayHello` method: ```rust,no_run use std::{error::Error, future::pending}; -use zbus::{connection, dbus_interface}; +use zbus::{connection, interface}; struct Greeter { count: u64 } -#[dbus_interface(name = "org.zbus.MyGreeter1")] +#[interface(name = "org.zbus.MyGreeter1")] impl Greeter { // Can be `async` as well. fn say_hello(&mut self, name: &str) -> String { @@ -79,9 +79,9 @@ s "Hello Maria! I have been called 1 times." Now let's write the client-side code for `MyGreeter` service: ```rust,no_run -use zbus::{Connection, Result, dbus_proxy}; +use zbus::{Connection, Result, proxy}; -#[dbus_proxy( +#[proxy( interface = "org.zbus.MyGreeter1", default_service = "org.zbus.MyGreeter", default_path = "/org/zbus/MyGreeter" @@ -95,7 +95,7 @@ trait MyGreeter { async fn main() -> Result<()> { let connection = Connection::session().await?; - // `dbus_proxy` macro creates `MyGreeterProxy` based on `Notifications` trait. + // `proxy` macro creates `MyGreeterProxy` based on `Notifications` trait. let proxy = MyGreeterProxy::new(&connection).await?; let reply = proxy.say_hello("Maria").await?; println!("{reply}"); diff --git a/book/src/blocking.md b/book/src/blocking.md index 391bfe8a4..3812bd48f 100644 --- a/book/src/blocking.md +++ b/book/src/blocking.md @@ -18,26 +18,26 @@ except all its methods are blocking. ## Client Similar to `blocking::Connection`, you use `blocking::Proxy` type. Its constructors require -`blocking::Connection` instead of `Connection`. Moreover, `dbus_proxy` macro generates a +`blocking::Connection` instead of `Connection`. Moreover, `proxy` macro generates a `blocking::Proxy` wrapper for you as well. Let's convert the last example in the previous chapter, to use the blocking connection and proxy: ```rust,no_run -use zbus::{blocking::Connection, zvariant::ObjectPath, dbus_proxy, Result}; +use zbus::{blocking::Connection, zvariant::ObjectPath, proxy, Result}; -#[dbus_proxy( +#[proxy( default_service = "org.freedesktop.GeoClue2", interface = "org.freedesktop.GeoClue2.Manager", default_path = "/org/freedesktop/GeoClue2/Manager" )] trait Manager { - #[dbus_proxy(object = "Client")] + #[zbus(object = "Client")] /// The method normally returns an `ObjectPath`. /// With the object attribute, we can make it return a `ClientProxy` directly. fn get_client(&self); } -#[dbus_proxy( +#[proxy( default_service = "org.freedesktop.GeoClue2", interface = "org.freedesktop.GeoClue2.Client" )] @@ -45,21 +45,21 @@ trait Client { fn start(&self) -> Result<()>; fn stop(&self) -> Result<()>; - #[dbus_proxy(property)] + #[zbus(property)] fn set_desktop_id(&mut self, id: &str) -> Result<()>; - #[dbus_proxy(signal)] + #[zbus(signal)] fn location_updated(&self, old: ObjectPath<'_>, new: ObjectPath<'_>) -> Result<()>; } -#[dbus_proxy( +#[proxy( default_service = "org.freedesktop.GeoClue2", interface = "org.freedesktop.GeoClue2.Location" )] trait Location { - #[dbus_proxy(property)] + #[zbus(property)] fn latitude(&self) -> Result; - #[dbus_proxy(property)] + #[zbus(property)] fn longitude(&self) -> Result; } let conn = Connection::system().unwrap(); @@ -88,7 +88,7 @@ println!( ); ``` -As you can see, nothing changed in the `dbus_proxy` usage here and the rest largely remained the +As you can see, nothing changed in the `proxy` usage here and the rest largely remained the same as well. One difference that's not obvious is that the blocking API for receiving signals, implement [`std::iter::Iterator`] trait instead of [`futures::stream::Stream`]. @@ -97,15 +97,15 @@ implement [`std::iter::Iterator`] trait instead of [`futures::stream::Stream`]. That's almost the same as receiving signals: ```rust,no_run -# use zbus::{blocking::Connection, dbus_proxy, Result}; +# use zbus::{blocking::Connection, proxy, Result}; # -#[dbus_proxy( +#[proxy( interface = "org.freedesktop.systemd1.Manager", default_service = "org.freedesktop.systemd1", default_path = "/org/freedesktop/systemd1" )] trait SystemdManager { - #[dbus_proxy(property)] + #[zbus(property)] fn log_level(&self) -> zbus::Result; } @@ -124,7 +124,7 @@ fn main() -> Result<()> { Similarly here, you'd use [`blocking::ObjectServer`] that is associated with every [`blocking::Connection`] instance. While there is no blocking version of `Interface`, -`dbus_interface` allows you to write non-async methods. +`interface` allows you to write non-async methods. **Note:** Even though you can write non-async methods, these methods are still called from an async context. Therefore, you can not use blocking API in the method implementation directly. See note at @@ -132,7 +132,7 @@ the beginning of this chapter for details on why and a possible workaround. ```rust,no_run # use std::error::Error; -# use zbus::{blocking::connection, dbus_interface, fdo, SignalContext}; +# use zbus::{blocking::connection, interface, fdo, SignalContext}; # use event_listener::Event; @@ -141,7 +141,7 @@ struct Greeter { done: Event, } -#[dbus_interface(name = "org.zbus.MyGreeter1")] +#[interface(name = "org.zbus.MyGreeter1")] impl Greeter { fn say_hello(&self, name: &str) -> String { format!("Hello {}!", name) @@ -160,7 +160,7 @@ impl Greeter { } /// A "GreeterName" property. - #[dbus_interface(property)] + #[zbus(property)] fn greeter_name(&self) -> &str { &self.name } @@ -170,13 +170,13 @@ impl Greeter { /// Additionally, a `greeter_name_changed` method has been generated for you if you need to /// notify listeners that "GreeterName" was updated. It will be automatically called when /// using this setter. - #[dbus_interface(property)] + #[zbus(property)] fn set_greeter_name(&mut self, name: String) { self.name = name; } /// A signal; the implementation is provided by the macro. - #[dbus_interface(signal)] + #[zbus(signal)] async fn greeted_everyone(ctxt: &SignalContext<'_>) -> zbus::Result<()>; } diff --git a/book/src/client.md b/book/src/client.md index d0a0483d9..42b696fd5 100644 --- a/book/src/client.md +++ b/book/src/client.md @@ -88,7 +88,7 @@ Instead, we want to wrap this `Notify` D-Bus method in a Rust function. Let's se ## Trait-derived proxy call -A trait declaration `T` with a `dbus_proxy` attribute will have a derived `TProxy` and +A trait declaration `T` with a `proxy` attribute will have a derived `TProxy` and `TProxyBlocking` (see [chapter on "blocking"][cob] for more information on that) implemented thanks to procedural macros. The trait methods will have respective `impl` methods wrapping the D-Bus calls: @@ -97,9 +97,9 @@ calls: use std::collections::HashMap; use std::error::Error; -use zbus::{zvariant::Value, dbus_proxy, Connection}; +use zbus::{zvariant::Value, proxy, Connection}; -#[dbus_proxy( +#[proxy( default_service = "org.freedesktop.Notifications", default_path = "/org/freedesktop/Notifications" )] @@ -163,21 +163,21 @@ Let's look at this API in action, with an example where we monitor started syste # // NOTE: When changing this, please also keep `zbus/examples/watch-systemd-jobs.rs` in sync. use async_std::stream::StreamExt; use zbus::Connection; -use zbus_macros::dbus_proxy; +use zbus_macros::proxy; use zvariant::OwnedObjectPath; # fn main() { # async_io::block_on(watch_systemd_jobs()).expect("Error listening to signal"); # } -#[dbus_proxy( +#[proxy( default_service = "org.freedesktop.systemd1", default_path = "/org/freedesktop/systemd1", interface = "org.freedesktop.systemd1.Manager" )] trait Systemd1Manager { // Defines signature for D-Bus signal named `JobNew` - #[dbus_proxy(signal)] + #[zbus(signal)] fn job_new(&self, id: u32, job: OwnedObjectPath, unit: String) -> zbus::Result<()>; } @@ -208,20 +208,20 @@ Here is a more elaborate example, where we get our location from [Geoclue](https://gitlab.freedesktop.org/geoclue/geoclue/-/blob/master/README.md): ```rust,no_run -use zbus::{zvariant::ObjectPath, dbus_proxy, Connection, Result}; +use zbus::{zvariant::ObjectPath, proxy, Connection, Result}; use futures_util::stream::StreamExt; -#[dbus_proxy( +#[proxy( default_service = "org.freedesktop.GeoClue2", interface = "org.freedesktop.GeoClue2.Manager", default_path = "/org/freedesktop/GeoClue2/Manager" )] trait Manager { - #[dbus_proxy(object = "Client")] + #[zbus(object = "Client")] fn get_client(&self); } -#[dbus_proxy( +#[proxy( default_service = "org.freedesktop.GeoClue2", interface = "org.freedesktop.GeoClue2.Client" )] @@ -229,21 +229,21 @@ trait Client { fn start(&self) -> Result<()>; fn stop(&self) -> Result<()>; - #[dbus_proxy(property)] + #[zbus(property)] fn set_desktop_id(&mut self, id: &str) -> Result<()>; - #[dbus_proxy(signal)] + #[zbus(signal)] fn location_updated(&self, old: ObjectPath<'_>, new: ObjectPath<'_>) -> Result<()>; } -#[dbus_proxy( +#[proxy( default_service = "org.freedesktop.GeoClue2", interface = "org.freedesktop.GeoClue2.Location" )] trait Location { - #[dbus_proxy(property)] + #[zbus(property)] fn latitude(&self) -> Result; - #[dbus_proxy(property)] + #[zbus(property)] fn longitude(&self) -> Result; } @@ -308,15 +308,15 @@ LOC) code for getting our location. ### Properties Interfaces can have associated properties, which can be read or set with the -`org.freedesktop.DBus.Properties` interface. Here again, the `#[dbus_proxy]` attribute comes to the +`org.freedesktop.DBus.Properties` interface. Here again, the `#[proxy]` attribute comes to the rescue to help you. You can annotate a trait method to be a getter: ```rust,noplayground -# use zbus::{dbus_proxy, Result}; +# use zbus::{proxy, Result}; # -#[dbus_proxy] +#[proxy] trait MyInterface { - #[dbus_proxy(property)] + #[zbus(property)] fn state(&self) -> Result; } ``` @@ -328,17 +328,17 @@ To set the property, prefix the name of the property with `set_`. For a more real world example, let's try and read two properties from systemd's main service: ```rust,no_run -# use zbus::{Connection, dbus_proxy, Result}; +# use zbus::{Connection, proxy, Result}; # -#[dbus_proxy( +#[proxy( interface = "org.freedesktop.systemd1.Manager", default_service = "org.freedesktop.systemd1", default_path = "/org/freedesktop/systemd1" )] trait SystemdManager { - #[dbus_proxy(property)] + #[zbus(property)] fn architecture(&self) -> Result; - #[dbus_proxy(property)] + #[zbus(property)] fn environment(&self) -> Result>; } @@ -396,18 +396,18 @@ methods are named after the properties' names: `receive__changed()`. Here is an example: ```rust,no_run -# use zbus::{Connection, dbus_proxy, Result}; +# use zbus::{Connection, proxy, Result}; # use futures_util::stream::StreamExt; # # #[async_std::main] # async fn main() -> Result<()> { - #[dbus_proxy( + #[proxy( interface = "org.freedesktop.systemd1.Manager", default_service = "org.freedesktop.systemd1", default_path = "/org/freedesktop/systemd1" )] trait SystemdManager { - #[dbus_proxy(property)] + #[zbus(property)] fn log_level(&self) -> Result; } @@ -526,9 +526,9 @@ This will give back effortlessly the corresponding Rust traits boilerplate code: ```rust,noplayground -# use zbus::dbus_proxy; +# use zbus::proxy; # -#[dbus_proxy( +#[proxy( interface = "org.freedesktop.Notifications", default_service = "org.freedesktop.Notifications", default_path= "/org/freedesktop/Notifications", @@ -557,11 +557,11 @@ trait Notifications { ) -> zbus::Result; /// ActionInvoked signal - #[dbus_proxy(signal)] + #[zbus(signal)] fn action_invoked(&self, arg_0: u32, arg_1: &str) -> zbus::Result<()>; /// NotificationClosed signal - #[dbus_proxy(signal)] + #[zbus(signal)] fn notification_closed(&self, arg_0: u32, arg_1: u32) -> zbus::Result<()>; } ``` @@ -574,7 +574,7 @@ For example, the generated `GetServerInformation` method can be improved to a ni ```rust,noplayground # use serde::{Serialize, Deserialize}; -# use zbus::{zvariant::Type, dbus_proxy}; +# use zbus::{zvariant::Type, proxy}; # #[derive(Debug, Type, Serialize, Deserialize)] pub struct ServerInformation { @@ -591,7 +591,7 @@ pub struct ServerInformation { pub spec_version: String, } -#[dbus_proxy( +#[proxy( interface = "org.freedesktop.Notifications", default_service = "org.freedesktop.Notifications", default_path= "/org/freedesktop/Notifications", diff --git a/book/src/faq.md b/book/src/faq.md index 006bfa536..e66333e5a 100644 --- a/book/src/faq.md +++ b/book/src/faq.md @@ -12,7 +12,7 @@ the `signature` attribute. Here is a simple example: ```rust,noplayground use zbus::{ - dbus_proxy, dbus_interface, fdo::Result, + proxy, interface, fdo::Result, zvariant::{DeserializeDict, SerializeDict, Type}, }; @@ -26,7 +26,7 @@ pub struct Dictionary { optional_field: Option, } -#[dbus_proxy( +#[proxy( interface = "org.zbus.DictionaryGiver", default_path = "/org/zbus/DictionaryGiver", default_service = "org.zbus.DictionaryGiver", @@ -37,7 +37,7 @@ trait DictionaryGiver { struct DictionaryGiverInterface; -#[dbus_interface(interface = "org.zbus.DictionaryGiver")] +#[interface(interface = "org.zbus.DictionaryGiver")] impl DictionaryGiverInterface { fn give_me(&self) -> Result { Ok(Dictionary { @@ -73,7 +73,7 @@ see [the corresponding tokio issue on GitHub][tctiog]. There are typically two reasons this can happen with zbus: -### 1. A `dbus_interface` method that takes a `&mut self` argument is taking too long +### 1. A `interface` method that takes a `&mut self` argument is taking too long Simply put, this is because of one of the primary rules of Rust: while a mutable reference to a resource exists, no other references to that same resource can exist at the same time. This means @@ -98,7 +98,7 @@ update accordingly. However, you can disabling caching for specific properties: -- Add the `#[dbus_proxy(property(emits_changed_signal = "false"))]` annotation to the property +- Add the `#[proxy(property(emits_changed_signal = "false"))]` annotation to the property for which you desire to disable caching on. - Use `proxy::Builder` to build your proxy instance and use `proxy::Builder::uncached_properties` method @@ -108,7 +108,7 @@ to list all properties you wish to disable caching for. method. For more information about all the possible values for `emits_changed_signal` refer - to [`dbus_proxy`](https://docs.rs/zbus/latest/zbus/attr.dbus_proxy.html) documentation. + to [`proxy`](https://docs.rs/zbus/latest/zbus/attr.proxy.html) documentation. ## How do I use `Option`` with zbus? @@ -137,7 +137,7 @@ all types. However, it does come with some caveats and limitations: nullable type, this can be confusing for users of generic tools like [`d-feet`]. It is therefore highly recommended that service authors document each use of `Option` in their D-Bus interface documentation. - 2. Currently it is not possible to use `Option` for `dbus_interface` and `dbus_proxy` property + 2. Currently it is not possible to use `Option` for `interface` and `proxy` property methods. 3. Both the sender and receiver must agree on use of this encoding. If the sender sends `T`, the receiver will not be able to decode it successfully as `Option` and vice versa. @@ -158,4 +158,4 @@ enabled. [dsi]: http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces [`Optional`]: https://docs.rs/zvariant/latest/zvariant/struct.Optional.html [`d-feet`]: https://wiki.gnome.org/Apps/DFeet -[specialization]: https://rust-lang.github.io/rfcs/1210-impl-specialization.html \ No newline at end of file +[specialization]: https://rust-lang.github.io/rfcs/1210-impl-specialization.html diff --git a/book/src/server.md b/book/src/server.md index 89812722b..ea3082382 100644 --- a/book/src/server.md +++ b/book/src/server.md @@ -99,7 +99,7 @@ need, but it is also easy to get it wrong. Fortunately, zbus has a simpler solut ## Using the `ObjectServer` -One can write an `impl` block with a set of methods and let the `dbus_interface` procedural macro +One can write an `impl` block with a set of methods and let the `interface` procedural macro write the D-Bus message handling details. It will dispatch the incoming method calls to their respective handlers, as well as replying to introspection requests. @@ -108,12 +108,12 @@ respective handlers, as well as replying to introspection requests. Let see how to use it for `MyGreeter` interface: ```rust,no_run -# use zbus::{Connection, dbus_interface, Result}; +# use zbus::{Connection, interface, Result}; # struct Greeter; -#[dbus_interface(name = "org.zbus.MyGreeter1")] +#[interface(name = "org.zbus.MyGreeter1")] impl Greeter { async fn say_hello(&self, name: &str) -> String { format!("Hello {}!", name) @@ -150,12 +150,12 @@ after taking their name. This is why it's typically better to make use of `conne setting up your interfaces and requesting names, and not have to care about this: ```rust,no_run -# use zbus::{connection, dbus_interface, Result}; +# use zbus::{connection, interface, Result}; # # # struct Greeter; # -# #[dbus_interface(name = "org.zbus.MyGreeter1")] +# #[interface(name = "org.zbus.MyGreeter1")] # impl Greeter { # async fn say_hello(&self, name: &str) -> String { # format!("Hello {}!", name) @@ -207,7 +207,7 @@ synchronize with the interface handlers from outside, thanks to the `event_liste (this is just one of the many ways). ```rust,no_run -# use zbus::{object_server::SignalContext, connection::Builder, dbus_interface, fdo, Result}; +# use zbus::{object_server::SignalContext, connection::Builder, interface, fdo, Result}; # use event_listener::Event; @@ -216,7 +216,7 @@ struct Greeter { done: Event, } -#[dbus_interface(name = "org.zbus.MyGreeter1")] +#[interface(name = "org.zbus.MyGreeter1")] impl Greeter { async fn say_hello(&self, name: &str) -> String { format!("Hello {}!", name) @@ -235,7 +235,7 @@ impl Greeter { } /// A "GreeterName" property. - #[dbus_interface(property)] + #[zbus(property)] async fn greeter_name(&self) -> &str { &self.name } @@ -245,13 +245,13 @@ impl Greeter { /// Additionally, a `greeter_name_changed` method has been generated for you if you need to /// notify listeners that "GreeterName" was updated. It will be automatically called when /// using this setter. - #[dbus_interface(property)] + #[zbus(property)] async fn set_greeter_name(&mut self, name: String) { self.name = name; } /// A signal; the implementation is provided by the macro. - #[dbus_interface(signal)] + #[zbus(signal)] async fn greeted_everyone(ctxt: &SignalContext<'_>) -> Result<()>; } @@ -307,34 +307,34 @@ you'll want to use `zbus::fdo::Error::UnknownProperty` variant. As you might have noticed in the previous example, the signal methods don't take a `&self` argument but a `SignalContext` reference. This allows to emit signals whether from inside or outside of the -`dbus_interface` methods' context. To make things simpler, `dbus_interface` methods can receive a +`interface` methods' context. To make things simpler, `interface` methods can receive a `SignalContext` passed to them using the special `zbus(signal_context)` attribute, as demonstrated in the previous example. -Please refer to [`dbus_interface` documentation][didoc] for more examples and list of other special +Please refer to [`interface` documentation][didoc] for more examples and list of other special attributes you can make use of. ### Notifying property changes -For each property declared through the `dbus_interface` macro, a `_changed` method is +For each property declared through the `interface` macro, a `_changed` method is generated that emits the necessary property change signal. Here is how to use it with the previous example code: ```rust,no_run -# use zbus::dbus_interface; +# use zbus::interface; # # struct Greeter { # name: String # } # -# #[dbus_interface(name = "org.zbus.MyGreeter1")] +# #[interface(name = "org.zbus.MyGreeter1")] # impl Greeter { -# #[dbus_interface(property)] +# #[zbus(property)] # async fn greeter_name(&self) -> &str { # &self.name # } # -# #[dbus_interface(property)] +# #[zbus(property)] # async fn set_greeter_name(&mut self, name: String) { # self.name = name; # } @@ -354,4 +354,4 @@ iface.greeter_name_changed(iface_ref.signal_context()).await?; ``` [D-Bus concepts]: concepts.html#bus-name--service-name -[didoc]: https://docs.rs/zbus/latest/zbus/attr.dbus_interface.html +[didoc]: https://docs.rs/zbus/latest/zbus/attr.interface.html diff --git a/zbus/README.md b/zbus/README.md index 48b8f7dc1..03fc96f6e 100644 --- a/zbus/README.md +++ b/zbus/README.md @@ -26,13 +26,13 @@ A simple service that politely greets whoever calls its `SayHello` method: ```rust,no_run use std::{error::Error, future::pending}; -use zbus::{connection, dbus_interface}; +use zbus::{connection, interface}; struct Greeter { count: u64 } -#[dbus_interface(name = "org.zbus.MyGreeter1")] +#[interface(name = "org.zbus.MyGreeter1")] impl Greeter { // Can be `async` as well. fn say_hello(&mut self, name: &str) -> String { @@ -70,9 +70,9 @@ s "Hello Maria! I have been called 1 times." Now let's write the client-side code for `MyGreeter` service: ```rust,no_run -use zbus::{Connection, Result, dbus_proxy}; +use zbus::{Connection, Result, proxy}; -#[dbus_proxy( +#[proxy( interface = "org.zbus.MyGreeter1", default_service = "org.zbus.MyGreeter", default_path = "/org/zbus/MyGreeter" @@ -86,7 +86,7 @@ trait MyGreeter { async fn main() -> Result<()> { let connection = Connection::session().await?; - // `dbus_proxy` macro creates `MyGreaterProxy` based on `Notifications` trait. + // `proxy` macro creates `MyGreaterProxy` based on `Notifications` trait. let proxy = MyGreeterProxy::new(&connection).await?; let reply = proxy.say_hello("Maria").await?; println!("{reply}"); diff --git a/zbus/examples/watch-systemd-jobs.rs b/zbus/examples/watch-systemd-jobs.rs index 5c800edba..fda5bf10c 100644 --- a/zbus/examples/watch-systemd-jobs.rs +++ b/zbus/examples/watch-systemd-jobs.rs @@ -6,21 +6,21 @@ use async_std::stream::StreamExt; use zbus::Connection; -use zbus_macros::dbus_proxy; +use zbus_macros::proxy; use zvariant::OwnedObjectPath; fn main() { async_io::block_on(watch_systemd_jobs()).expect("Error listening to signal"); } -#[dbus_proxy( +#[proxy( default_service = "org.freedesktop.systemd1", default_path = "/org/freedesktop/systemd1", interface = "org.freedesktop.systemd1.Manager" )] trait Systemd1Manager { // Defines signature for D-Bus signal named `JobNew` - #[dbus_proxy(signal)] + #[zbus(signal)] fn job_new(&self, id: u32, job: OwnedObjectPath, unit: String) -> zbus::Result<()>; } diff --git a/zbus/src/blocking/fdo.rs b/zbus/src/blocking/fdo.rs index 75d427b33..1c71f2142 100644 --- a/zbus/src/blocking/fdo.rs +++ b/zbus/src/blocking/fdo.rs @@ -12,12 +12,11 @@ use zbus_names::{ use zvariant::{ObjectPath, Optional, OwnedValue, Value}; use crate::{ - dbus_proxy, fdo::{ ConnectionCredentials, ManagedObjects, ReleaseNameReply, RequestNameFlags, RequestNameReply, Result, }, - Guid, + proxy, Guid, }; gen_introspectable_proxy!(false, true); diff --git a/zbus/src/blocking/mod.rs b/zbus/src/blocking/mod.rs index 2036b88f0..37c26550b 100644 --- a/zbus/src/blocking/mod.rs +++ b/zbus/src/blocking/mod.rs @@ -9,7 +9,7 @@ //! //! Since methods provided by these types run their own little runtime (`block_on`), you must not //! use them in async contexts because of the infamous [async sandwich footgun][asf]. This is -//! an especially important fact to keep in mind for [`crate::dbus_interface`]. While +//! an especially important fact to keep in mind for [`crate::interface`]. While //! `dbus_interface` allows non-async methods for convenience, these methods are called from an //! async context. The [`blocking` crate] provides an easy way around this problem though. //! diff --git a/zbus/src/blocking/object_server.rs b/zbus/src/blocking/object_server.rs index 30ef9c55e..796661ef8 100644 --- a/zbus/src/blocking/object_server.rs +++ b/zbus/src/blocking/object_server.rs @@ -41,13 +41,13 @@ where /// ```no_run /// # use std::error::Error; /// # use async_io::block_on; - /// # use zbus::{blocking::Connection, dbus_interface}; + /// # use zbus::{blocking::Connection, interface}; /// /// struct MyIface(u32); /// - /// #[dbus_interface(name = "org.myiface.MyIface")] + /// #[interface(name = "org.myiface.MyIface")] /// impl MyIface { - /// #[dbus_interface(property)] + /// #[zbus(property)] /// fn count(&self) -> u32 { /// self.0 /// } @@ -84,7 +84,7 @@ where /// /// ```no_run /// # use std::error::Error; -/// use zbus::{blocking::Connection, dbus_interface}; +/// use zbus::{blocking::Connection, interface}; /// use event_listener::Event; /// /// struct Example { @@ -99,14 +99,14 @@ where /// } /// } /// -/// #[dbus_interface(name = "org.myiface.Example")] +/// #[interface(name = "org.myiface.Example")] /// impl Example { /// // This will be the "Quit" D-Bus method. /// fn quit(&mut self) { /// self.quit_event.notify(1); /// } /// -/// // See `dbus_interface` documentation to learn +/// // See `interface` documentation to learn /// // how to expose properties & signals as well. /// } /// @@ -189,13 +189,13 @@ impl ObjectServer { /// # use zbus::{ /// # SignalContext, /// # blocking::Connection, - /// # dbus_interface, + /// # interface, /// # }; /// # /// struct MyIface; - /// #[dbus_interface(name = "org.myiface.MyIface")] + /// #[interface(name = "org.myiface.MyIface")] /// impl MyIface { - /// #[dbus_interface(signal)] + /// #[zbus(signal)] /// async fn emit_signal(ctxt: &SignalContext<'_>) -> zbus::Result<()>; /// } /// diff --git a/zbus/src/blocking/proxy/mod.rs b/zbus/src/blocking/proxy/mod.rs index df40e1b97..1aeec3f0a 100644 --- a/zbus/src/blocking/proxy/mod.rs +++ b/zbus/src/blocking/proxy/mod.rs @@ -47,14 +47,14 @@ pub use builder::Builder; /// /// # Note /// -/// It is recommended to use the [`dbus_proxy`] macro, which provides a more convenient and +/// It is recommended to use the [`proxy`] macro, which provides a more convenient and /// type-safe *façade* `Proxy` derived from a Rust trait. /// /// ## Current limitations: /// /// At the moment, `Proxy` doesn't prevent [auto-launching][al]. /// -/// [`dbus_proxy`]: attr.dbus_proxy.html +/// [`proxy`]: attr.proxy.html /// [al]: https://github.com/dbus2/zbus/issues/54 #[derive(derivative::Derivative)] #[derivative(Clone, Debug)] diff --git a/zbus/src/connection/mod.rs b/zbus/src/connection/mod.rs index d807cb7df..125aab6fe 100644 --- a/zbus/src/connection/mod.rs +++ b/zbus/src/connection/mod.rs @@ -91,7 +91,7 @@ pub(crate) type MsgBroadcaster = Broadcaster>; /// /// For higher-level message handling (typed functions, introspection, documentation reasons etc), /// it is recommended to wrap the low-level D-Bus messages into Rust functions with the -/// [`dbus_proxy`] and [`dbus_interface`] macros instead of doing it directly on a `Connection`. +/// [`proxy`] and [`interface`] macros instead of doing it directly on a `Connection`. /// /// Typically, a connection is made to the session bus with [`Connection::session`], or to the /// system bus with [`Connection::system`]. Then the connection is used with [`crate::Proxy`] @@ -114,8 +114,8 @@ pub(crate) type MsgBroadcaster = Broadcaster>; /// /// [method calls]: struct.Connection.html#method.call_method /// [signals]: struct.Connection.html#method.emit_signal -/// [`dbus_proxy`]: attr.dbus_proxy.html -/// [`dbus_interface`]: attr.dbus_interface.html +/// [`proxy`]: attr.proxy.html +/// [`interface`]: attr.interface.html /// [`Clone`]: https://doc.rust-lang.org/std/clone/trait.Clone.html /// [`set_max_queued`]: struct.Connection.html#method.set_max_queued /// @@ -849,7 +849,7 @@ impl Connection { /// /// # struct SomeIface; /// # - /// # #[zbus::dbus_interface] + /// # #[zbus::interface] /// # impl SomeIface { /// # } /// # @@ -1600,7 +1600,7 @@ mod tests { #[derive(Default)] struct MyInterface {} - #[crate::dbus_interface(name = "dev.peelz.FooBar.Baz")] + #[crate::interface(name = "dev.peelz.FooBar.Baz")] impl MyInterface { fn do_thing(&self) {} } diff --git a/zbus/src/fdo.rs b/zbus/src/fdo.rs index 20e99c024..3f4e65006 100644 --- a/zbus/src/fdo.rs +++ b/zbus/src/fdo.rs @@ -17,15 +17,14 @@ use zvariant::{ }; use crate::{ - dbus_interface, dbus_proxy, message::Header, object_server::SignalContext, DBusError, Guid, - ObjectServer, + interface, message::Header, object_server::SignalContext, proxy, DBusError, Guid, ObjectServer, }; #[rustfmt::skip] macro_rules! gen_introspectable_proxy { ($gen_async:literal, $gen_blocking:literal) => { /// Proxy for the `org.freedesktop.DBus.Introspectable` interface. - #[dbus_proxy( + #[proxy( interface = "org.freedesktop.DBus.Introspectable", default_path = "/", gen_async = $gen_async, @@ -47,7 +46,7 @@ assert_impl_all!(IntrospectableProxy<'_>: Send, Sync, Unpin); /// [ObjectServer](crate::ObjectServer). pub(crate) struct Introspectable; -#[dbus_interface(name = "org.freedesktop.DBus.Introspectable")] +#[interface(name = "org.freedesktop.DBus.Introspectable")] impl Introspectable { async fn introspect( &self, @@ -69,7 +68,7 @@ impl Introspectable { macro_rules! gen_properties_proxy { ($gen_async:literal, $gen_blocking:literal) => { /// Proxy for the `org.freedesktop.DBus.Properties` interface. - #[dbus_proxy( + #[proxy( interface = "org.freedesktop.DBus.Properties", gen_async = $gen_async, gen_blocking = $gen_blocking, @@ -96,7 +95,7 @@ macro_rules! gen_properties_proxy { interface_name: Optional>, ) -> Result>; - #[dbus_proxy(signal)] + #[zbus(signal)] async fn properties_changed( &self, interface_name: InterfaceName<'_>, @@ -117,7 +116,7 @@ pub struct Properties; assert_impl_all!(Properties: Send, Sync, Unpin); -#[dbus_interface(name = "org.freedesktop.DBus.Properties")] +#[interface(name = "org.freedesktop.DBus.Properties")] impl Properties { async fn get( &self, @@ -207,7 +206,7 @@ impl Properties { } /// Emits the `org.freedesktop.DBus.Properties.PropertiesChanged` signal. - #[dbus_interface(signal)] + #[zbus(signal)] #[rustfmt::skip] pub async fn properties_changed( ctxt: &SignalContext<'_>, @@ -229,7 +228,7 @@ macro_rules! gen_object_manager_proxy { /// **NB:** Changes to properties on existing interfaces are not reported using this interface. /// Please use [`PropertiesProxy::receive_properties_changed`] to monitor changes to properties on /// objects. - #[dbus_proxy( + #[proxy( interface = "org.freedesktop.DBus.ObjectManager", gen_async = $gen_async, gen_blocking = $gen_blocking, @@ -248,7 +247,7 @@ macro_rules! gen_object_manager_proxy { /// This signal is emitted when either a new object is added or when an existing object gains /// one or more interfaces. The `interfaces_and_properties` argument contains a map with the /// interfaces and properties (if any) that have been added to the given object path. - #[dbus_proxy(signal)] + #[zbus(signal)] fn interfaces_added( &self, object_path: ObjectPath<'_>, @@ -257,7 +256,7 @@ macro_rules! gen_object_manager_proxy { /// This signal is emitted whenever an object is removed or it loses one or more interfaces. /// The `interfaces` parameters contains a list of the interfaces that were removed. - #[dbus_proxy(signal)] + #[zbus(signal)] fn interfaces_removed( &self, object_path: ObjectPath<'_>, @@ -287,7 +286,7 @@ assert_impl_all!(ObjectManagerProxy<'_>: Send, Sync, Unpin); #[derive(Debug, Clone)] pub struct ObjectManager; -#[dbus_interface(name = "org.freedesktop.DBus.ObjectManager")] +#[interface(name = "org.freedesktop.DBus.ObjectManager")] impl ObjectManager { async fn get_managed_objects( &self, @@ -307,7 +306,7 @@ impl ObjectManager { /// This signal is emitted when either a new object is added or when an existing object gains /// one or more interfaces. The `interfaces_and_properties` argument contains a map with the /// interfaces and properties (if any) that have been added to the given object path. - #[dbus_interface(signal)] + #[zbus(signal)] pub async fn interfaces_added( ctxt: &SignalContext<'_>, object_path: &ObjectPath<'_>, @@ -316,7 +315,7 @@ impl ObjectManager { /// This signal is emitted whenever an object is removed or it loses one or more interfaces. /// The `interfaces` parameters contains a list of the interfaces that were removed. - #[dbus_interface(signal)] + #[zbus(signal)] pub async fn interfaces_removed( ctxt: &SignalContext<'_>, object_path: &ObjectPath<'_>, @@ -328,7 +327,7 @@ impl ObjectManager { macro_rules! gen_peer_proxy { ($gen_async:literal, $gen_blocking:literal) => { /// Proxy for the `org.freedesktop.DBus.Peer` interface. - #[dbus_proxy( + #[proxy( interface = "org.freedesktop.DBus.Peer", gen_async = $gen_async, gen_blocking = $gen_blocking, @@ -356,7 +355,7 @@ pub(crate) struct Peer; /// Server-side implementation for the `org.freedesktop.DBus.Peer` interface. /// This interface is implemented automatically for any object registered to the /// [ObjectServer](crate::ObjectServer). -#[dbus_interface(name = "org.freedesktop.DBus.Peer")] +#[interface(name = "org.freedesktop.DBus.Peer")] impl Peer { fn ping(&self) {} @@ -384,7 +383,7 @@ impl Peer { macro_rules! gen_monitoring_proxy { ($gen_async:literal, $gen_blocking:literal) => { /// Proxy for the `org.freedesktop.DBus.Monitoring` interface. - #[dbus_proxy( + #[proxy( interface = "org.freedesktop.DBus.Monitoring", default_service = "org.freedesktop.DBus", default_path = "/org/freedesktop/DBus", @@ -428,7 +427,7 @@ assert_impl_all!(MonitoringProxy<'_>: Send, Sync, Unpin); macro_rules! gen_stats_proxy { ($gen_async:literal, $gen_blocking:literal) => { /// Proxy for the `org.freedesktop.DBus.Debug.Stats` interface. - #[dbus_proxy( + #[proxy( interface = "org.freedesktop.DBus.Debug.Stats", default_service = "org.freedesktop.DBus", default_path = "/org/freedesktop/DBus", @@ -695,16 +694,15 @@ impl ConnectionCredentials { macro_rules! gen_dbus_proxy { ($gen_async:literal, $gen_blocking:literal) => { /// Proxy for the `org.freedesktop.DBus` interface. - #[dbus_proxy( - default_service = "org.freedesktop.DBus", - default_path = "/org/freedesktop/DBus", + #[proxy( + assume_defaults = true, interface = "org.freedesktop.DBus", gen_async = $gen_async, gen_blocking = $gen_blocking, )] trait DBus { /// Adds a match rule to match messages going through the message bus - #[dbus_proxy(name = "AddMatch")] + #[zbus(name = "AddMatch")] fn add_match_rule(&self, rule: crate::MatchRule<'_>) -> Result<()>; /// Returns auditing data used by Solaris ADT, in an unspecified binary format. @@ -717,14 +715,14 @@ macro_rules! gen_dbus_proxy { ) -> Result; /// Returns the security context used by SELinux, in an unspecified format. - #[dbus_proxy(name = "GetConnectionSELinuxSecurityContext")] + #[zbus(name = "GetConnectionSELinuxSecurityContext")] fn get_connection_selinux_security_context( &self, bus_name: BusName<'_>, ) -> Result>; /// Returns the Unix process ID of the process connected to the server. - #[dbus_proxy(name = "GetConnectionUnixProcessID")] + #[zbus(name = "GetConnectionUnixProcessID")] fn get_connection_unix_process_id(&self, bus_name: BusName<'_>) -> Result; /// Returns the Unix user ID of the process connected to the server. @@ -758,7 +756,7 @@ macro_rules! gen_dbus_proxy { fn reload_config(&self) -> Result<()>; /// Removes the first rule that matches. - #[dbus_proxy(name = "RemoveMatch")] + #[zbus(name = "RemoveMatch")] fn remove_match_rule(&self, rule: crate::MatchRule<'_>) -> Result<()>; /// Ask the message bus to assign the given name to the method caller. @@ -779,7 +777,7 @@ macro_rules! gen_dbus_proxy { /// This signal indicates that the owner of a name has /// changed. It's also the signal to use to detect the appearance /// of new names on the bus. - #[dbus_proxy(signal)] + #[zbus(signal)] fn name_owner_changed( &self, name: BusName<'_>, @@ -788,16 +786,16 @@ macro_rules! gen_dbus_proxy { ); /// This signal is sent to a specific application when it loses ownership of a name. - #[dbus_proxy(signal)] + #[zbus(signal)] fn name_lost(&self, name: BusName<'_>); /// This signal is sent to a specific application when it gains ownership of a name. - #[dbus_proxy(signal)] + #[zbus(signal)] fn name_acquired(&self, name: BusName<'_>); /// This property lists abstract “features” provided by the message bus, and can be used by /// clients to detect the capabilities of the message bus with which they are communicating. - #[dbus_proxy(property)] + #[zbus(property)] fn features(&self) -> Result>; /// This property lists interfaces provided by the `/org/freedesktop/DBus` object, and can be @@ -812,7 +810,7 @@ macro_rules! gen_dbus_proxy { /// `org.freedesktop.DBus` was successful. The standard `org.freedesktop.DBus.Peer` and /// `org.freedesktop.DBus.Introspectable` interfaces are not included in the value of this /// property either, because they do not indicate features of the message bus implementation. - #[dbus_proxy(property)] + #[zbus(property)] fn interfaces(&self) -> Result>; } }; @@ -823,11 +821,11 @@ assert_impl_all!(DBusProxy<'_>: Send, Sync, Unpin); /// Errors from #[derive(Clone, Debug, DBusError, PartialEq)] -#[dbus_error(prefix = "org.freedesktop.DBus.Error", impl_display = true)] +#[zbus(prefix = "org.freedesktop.DBus.Error", impl_display = true)] #[allow(clippy::upper_case_acronyms)] pub enum Error { /// Unknown or fall-through ZBus error. - #[dbus_error(zbus_error)] + #[zbus(zbus)] ZBus(zbus::Error), /// A generic error; "something went wrong" - see the error message for more. @@ -913,51 +911,51 @@ pub enum Error { MatchRuleInvalid(String), /// While starting a new process, the exec() call failed. - #[dbus_error(name = "Spawn.ExecFailed")] + #[zbus(name = "Spawn.ExecFailed")] SpawnExecFailed(String), /// While starting a new process, the fork() call failed. - #[dbus_error(name = "Spawn.ForkFailed")] + #[zbus(name = "Spawn.ForkFailed")] SpawnForkFailed(String), /// While starting a new process, the child exited with a status code. - #[dbus_error(name = "Spawn.ChildExited")] + #[zbus(name = "Spawn.ChildExited")] SpawnChildExited(String), /// While starting a new process, the child exited on a signal. - #[dbus_error(name = "Spawn.ChildSignaled")] + #[zbus(name = "Spawn.ChildSignaled")] SpawnChildSignaled(String), /// While starting a new process, something went wrong. - #[dbus_error(name = "Spawn.Failed")] + #[zbus(name = "Spawn.Failed")] SpawnFailed(String), /// We failed to setup the environment correctly. - #[dbus_error(name = "Spawn.FailedToSetup")] + #[zbus(name = "Spawn.FailedToSetup")] SpawnFailedToSetup(String), /// We failed to setup the config parser correctly. - #[dbus_error(name = "Spawn.ConfigInvalid")] + #[zbus(name = "Spawn.ConfigInvalid")] SpawnConfigInvalid(String), /// Bus name was not valid. - #[dbus_error(name = "Spawn.ServiceNotValid")] + #[zbus(name = "Spawn.ServiceNotValid")] SpawnServiceNotValid(String), /// Service file not found in system-services directory. - #[dbus_error(name = "Spawn.ServiceNotFound")] + #[zbus(name = "Spawn.ServiceNotFound")] SpawnServiceNotFound(String), /// Permissions are incorrect on the setuid helper. - #[dbus_error(name = "Spawn.PermissionsInvalid")] + #[zbus(name = "Spawn.PermissionsInvalid")] SpawnPermissionsInvalid(String), /// Service file invalid (Name, User or Exec missing). - #[dbus_error(name = "Spawn.FileInvalid")] + #[zbus(name = "Spawn.FileInvalid")] SpawnFileInvalid(String), /// There was not enough memory to complete the operation. - #[dbus_error(name = "Spawn.NoMemory")] + #[zbus(name = "Spawn.NoMemory")] SpawnNoMemory(String), /// Tried to get a UNIX process ID and it wasn't available. @@ -1115,9 +1113,9 @@ mod tests { // Now create the service side. struct TestObj; - #[super::dbus_interface(name = "org.zbus.TestObj")] + #[super::interface(name = "org.zbus.TestObj")] impl TestObj { - #[dbus_interface(property)] + #[zbus(property)] fn test(&self) -> String { "test".into() } diff --git a/zbus/src/lib.rs b/zbus/src/lib.rs index 6100c4936..1779349cc 100644 --- a/zbus/src/lib.rs +++ b/zbus/src/lib.rs @@ -172,7 +172,9 @@ pub use connection::Socket; pub mod blocking; -pub use zbus_macros::{dbus_interface, dbus_proxy, DBusError}; +pub use zbus_macros::{interface, proxy, DBusError}; +// Old names used for backwards compatibility +pub use zbus_macros::{dbus_interface, dbus_proxy}; // Required for the macros to function within this crate. extern crate self as zbus; @@ -581,14 +583,14 @@ mod tests { fn issue104() { // Tests the fix for https://github.com/dbus2/zbus/issues/104 // - // The issue is caused by `dbus_proxy` macro adding `()` around the return value of methods + // The issue is caused by `proxy` macro adding `()` around the return value of methods // with multiple out arguments, ending up with double parenthesis around the signature of // the return type and zbus only removing the outer `()` only and then it not matching the // signature we receive on the reply message. use zvariant::{ObjectPath, Value}; struct Secret; - #[super::dbus_interface(name = "org.freedesktop.Secret.Service")] + #[super::interface(name = "org.freedesktop.Secret.Service")] impl Secret { fn open_session( &self, @@ -615,7 +617,7 @@ mod tests { { let conn = blocking::Connection::session().unwrap(); - #[super::dbus_proxy( + #[super::proxy( interface = "org.freedesktop.Secret.Service", assume_defaults = true, gen_async = false @@ -648,16 +650,16 @@ mod tests { #[test] #[ignore] fn issue_121() { - use crate::dbus_proxy; + use crate::proxy; - #[dbus_proxy(interface = "org.freedesktop.IBus", assume_defaults = true)] + #[proxy(interface = "org.freedesktop.IBus", assume_defaults = true)] trait IBus { /// CurrentInputContext property - #[dbus_proxy(property)] + #[zbus(property)] fn current_input_context(&self) -> zbus::Result; /// Engines property - #[dbus_proxy(property)] + #[zbus(property)] fn engines(&self) -> zbus::Result>; } } @@ -715,7 +717,7 @@ mod tests { #[test] #[ignore] fn issue_81() { - use zbus::dbus_proxy; + use zbus::proxy; use zvariant::{OwnedValue, Type}; #[derive( @@ -726,12 +728,12 @@ mod tests { path: OwnedObjectPath, } - #[dbus_proxy(assume_defaults = true)] + #[proxy(assume_defaults = true)] trait Session { - #[dbus_proxy(property)] + #[zbus(property)] fn sessions_tuple(&self) -> zbus::Result<(String, String)>; - #[dbus_proxy(property)] + #[zbus(property)] fn sessions_struct(&self) -> zbus::Result; } } @@ -746,13 +748,13 @@ mod tests { let (tx, rx) = channel(); let child = std::thread::spawn(move || { let conn = blocking::Connection::session().unwrap(); - #[super::dbus_proxy( + #[super::proxy( interface = "org.freedesktop.zbus.ComeAndGo", default_service = "org.freedesktop.zbus.ComeAndGo", default_path = "/org/freedesktop/zbus/ComeAndGo" )] trait ComeAndGo { - #[dbus_proxy(signal)] + #[zbus(signal)] fn the_signal(&self) -> zbus::Result<()>; } @@ -768,9 +770,9 @@ mod tests { }); struct ComeAndGo; - #[super::dbus_interface(name = "org.freedesktop.zbus.ComeAndGo")] + #[super::interface(name = "org.freedesktop.zbus.ComeAndGo")] impl ComeAndGo { - #[dbus_interface(signal)] + #[zbus(signal)] async fn the_signal(signal_ctxt: &SignalContext<'_>) -> zbus::Result<()>; } @@ -813,13 +815,13 @@ mod tests { // and without caching. #[derive(Default)] struct ServiceUncachedPropertyTest(bool); - #[crate::dbus_interface(name = "org.freedesktop.zbus.UncachedPropertyTest")] + #[crate::interface(name = "org.freedesktop.zbus.UncachedPropertyTest")] impl ServiceUncachedPropertyTest { - #[dbus_interface(property)] + #[zbus(property)] fn cached_prop(&self) -> bool { self.0 } - #[dbus_interface(property)] + #[zbus(property)] fn uncached_prop(&self) -> bool { self.0 } @@ -829,16 +831,16 @@ mod tests { } } - #[crate::dbus_proxy( + #[crate::proxy( interface = "org.freedesktop.zbus.UncachedPropertyTest", default_service = "org.freedesktop.zbus.UncachedPropertyTest", default_path = "/org/freedesktop/zbus/UncachedPropertyTest" )] trait UncachedPropertyTest { - #[dbus_proxy(property)] + #[zbus(property)] fn cached_prop(&self) -> zbus::Result; - #[dbus_proxy(property(emits_changed_signal = "false"))] + #[zbus(property(emits_changed_signal = "false"))] fn uncached_prop(&self) -> zbus::Result; fn set_inner_to_true(&self) -> zbus::Result<()>; @@ -978,9 +980,9 @@ mod tests { struct Station(u64); - #[zbus::dbus_interface(name = "net.connman.iwd.Station")] + #[zbus::interface(name = "net.connman.iwd.Station")] impl Station { - #[dbus_interface(property)] + #[zbus(property)] fn connected_network(&self) -> OwnedObjectPath { format!("/net/connman/iwd/0/33/Network/{}", self.0) .try_into() @@ -988,12 +990,12 @@ mod tests { } } - #[zbus::dbus_proxy( + #[zbus::proxy( interface = "net.connman.iwd.Station", default_service = "net.connman.iwd" )] trait Station { - #[dbus_proxy(property)] + #[zbus(property)] fn connected_network(&self) -> zbus::Result; } let connection = Builder::session() @@ -1061,14 +1063,14 @@ mod tests { #[test] #[ignore] fn issue_466() { - #[crate::dbus_proxy(interface = "org.Some.Thing1", assume_defaults = true)] + #[crate::proxy(interface = "org.Some.Thing1", assume_defaults = true)] trait MyGreeter { fn foo( &self, arg: &(u32, zbus::zvariant::Value<'_>), ) -> zbus::Result<(u32, zbus::zvariant::OwnedValue)>; - #[dbus_proxy(property)] + #[zbus(property)] fn bar(&self) -> zbus::Result<(u32, zbus::zvariant::OwnedValue)>; } } diff --git a/zbus/src/object_server/mod.rs b/zbus/src/object_server/mod.rs index 5fee39961..bb32b211f 100644 --- a/zbus/src/object_server/mod.rs +++ b/zbus/src/object_server/mod.rs @@ -122,13 +122,13 @@ where /// ```no_run /// # use std::error::Error; /// # use async_io::block_on; - /// # use zbus::{Connection, dbus_interface}; + /// # use zbus::{Connection, interface}; /// /// struct MyIface(u32); /// - /// #[dbus_interface(name = "org.myiface.MyIface")] + /// #[interface(name = "org.myiface.MyIface")] /// impl MyIface { - /// #[dbus_interface(property)] + /// #[zbus(property)] /// async fn count(&self) -> u32 { /// self.0 /// } @@ -433,7 +433,7 @@ impl Node { /// /// ```no_run /// # use std::error::Error; -/// use zbus::{Connection, dbus_interface}; +/// use zbus::{Connection, interface}; /// use event_listener::Event; /// # use async_io::block_on; /// @@ -449,14 +449,14 @@ impl Node { /// } /// } /// -/// #[dbus_interface(name = "org.myiface.Example")] +/// #[interface(name = "org.myiface.Example")] /// impl Example { /// // This will be the "Quit" D-Bus method. /// async fn quit(&mut self) { /// self.quit_event.notify(1); /// } /// -/// // See `dbus_interface` documentation to learn +/// // See `interface` documentation to learn /// // how to expose properties & signals as well. /// } /// @@ -636,14 +636,14 @@ impl ObjectServer { /// /// ```no_run /// # use std::error::Error; - /// # use zbus::{Connection, dbus_interface}; + /// # use zbus::{Connection, interface}; /// # use async_io::block_on; /// # /// struct MyIface(u32); /// - /// #[dbus_interface(name = "org.myiface.MyIface")] + /// #[interface(name = "org.myiface.MyIface")] /// impl MyIface { - /// #[dbus_interface(property)] + /// #[zbus(property)] /// async fn count(&self) -> u32 { /// self.0 /// } @@ -816,7 +816,7 @@ impl From for ObjectServer { /// A response wrapper that notifies after response has been sent. /// -/// Sometimes in [`dbus_interface`] method implemenations we need to do some other work after the +/// Sometimes in [`interface`] method implemenations we need to do some other work after the /// response has been sent off. This wrapper type allows us to do that. Instead of returning your /// intended response type directly, wrap it in this type and return it from your method. The /// returned `EventListener` from `new` method will be notified when the response has been sent. @@ -830,7 +830,7 @@ impl From for ObjectServer { /// The notification indicates that the response has been sent off, not that destination peer has /// received it. That can only be guaranteed for a peer-to-peer connection. /// -/// [`dbus_interface`]: crate::dbus_interface +/// [`interface`]: crate::interface #[derive(Debug)] pub struct ResponseDispatchNotifier { response: R, diff --git a/zbus/src/object_server/signal_context.rs b/zbus/src/object_server/signal_context.rs index 852bb23b7..2a74e4b3d 100644 --- a/zbus/src/object_server/signal_context.rs +++ b/zbus/src/object_server/signal_context.rs @@ -6,7 +6,7 @@ use crate::{zvariant::ObjectPath, Connection, Error, Result}; /// /// For signal emission using the high-level API, you'll need instances of this type. /// -/// See [`crate::InterfaceRef::signal_context`] and [`crate::dbus_interface`] +/// See [`crate::InterfaceRef::signal_context`] and [`crate::interface`] /// documentation for details and examples of this type in use. #[derive(Clone, Debug)] pub struct SignalContext<'s> { diff --git a/zbus/src/proxy/mod.rs b/zbus/src/proxy/mod.rs index 3023e9763..33bd08ecd 100644 --- a/zbus/src/proxy/mod.rs +++ b/zbus/src/proxy/mod.rs @@ -61,11 +61,11 @@ pub use builder::{Builder, CacheProperties, ProxyDefault}; /// /// # Note /// -/// It is recommended to use the [`dbus_proxy`] macro, which provides a more convenient and +/// It is recommended to use the [`proxy`] macro, which provides a more convenient and /// type-safe *façade* `Proxy` derived from a Rust trait. /// /// [`futures` crate]: https://crates.io/crates/futures -/// [`dbus_proxy`]: attr.dbus_proxy.html +/// [`proxy`]: attr.proxy.html #[derive(Clone, Debug)] pub struct Proxy<'a> { pub(crate) inner: Arc>, @@ -1344,8 +1344,7 @@ where mod tests { use super::*; use crate::{ - connection, dbus_interface, dbus_proxy, object_server::SignalContext, utils::block_on, - AsyncDrop, + connection, interface, object_server::SignalContext, proxy, utils::block_on, AsyncDrop, }; use futures_util::StreamExt; use ntest::timeout; @@ -1433,22 +1432,22 @@ mod tests { /// signal listener is created against another signal. Previously, this second /// call to add the match rule never resolved and resulted in a deadlock. async fn test_signal_stream_deadlock() -> Result<()> { - #[dbus_proxy( + #[proxy( gen_blocking = false, default_path = "/org/zbus/Test", default_service = "org.zbus.Test.MR501", interface = "org.zbus.Test" )] trait Test { - #[dbus_proxy(signal)] + #[zbus(signal)] fn my_signal(&self, msg: &str) -> Result<()>; } struct TestIface; - #[dbus_interface(name = "org.zbus.Test")] + #[interface(name = "org.zbus.Test")] impl TestIface { - #[dbus_interface(signal)] + #[zbus(signal)] async fn my_signal(context: &SignalContext<'_>, msg: &'static str) -> Result<()>; } diff --git a/zbus/tests/e2e.rs b/zbus/tests/e2e.rs index 0faaad0c2..730d576b9 100644 --- a/zbus/tests/e2e.rs +++ b/zbus/tests/e2e.rs @@ -22,9 +22,10 @@ use zbus::{ use zvariant::{DeserializeDict, Optional, OwnedValue, SerializeDict, Str, Type, Value}; use zbus::{ - connection, dbus_interface, dbus_proxy, + connection, interface, message::Header, object_server::{InterfaceRef, SignalContext}, + proxy, proxy::CacheProperties, Connection, ObjectServer, }; @@ -51,7 +52,7 @@ pub struct RefType<'a> { field1: Str<'a>, } -#[dbus_proxy(assume_defaults = true, gen_blocking = true)] +#[proxy(assume_defaults = true, gen_blocking = true)] trait MyIface { fn ping(&self) -> zbus::Result; @@ -79,79 +80,79 @@ trait MyIface { // Optional params and return values. fn optional_args(&self, key: Option<&str>) -> zbus::Result>; - #[dbus_proxy(property)] + #[zbus(property)] fn count(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn set_count(&self, count: u32) -> zbus::Result<()>; - #[dbus_proxy(property)] + #[zbus(property)] fn hash_map(&self) -> zbus::Result>; - #[dbus_proxy(property)] + #[zbus(property)] fn address_data(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn set_address_data(&self, addr: IP4Adress) -> zbus::Result<()>; - #[dbus_proxy(property)] + #[zbus(property)] fn address_data2(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn str_prop(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn set_str_prop(&self, str_prop: &str) -> zbus::Result<()>; - #[dbus_proxy(property)] + #[zbus(property)] fn ref_type(&self) -> zbus::Result>; - #[dbus_proxy(property)] + #[zbus(property)] fn set_ref_type(&self, ref_type: RefType<'_>) -> zbus::Result<()>; - #[dbus_proxy(property)] + #[zbus(property)] fn fail_property(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn optional_property(&self) -> zbus::Result>; - #[dbus_proxy(no_reply)] + #[zbus(no_reply)] fn test_no_reply(&self) -> zbus::Result<()>; - #[dbus_proxy(no_autostart)] + #[zbus(no_autostart)] fn test_no_autostart(&self) -> zbus::Result<()>; - #[dbus_proxy(allow_interactive_auth)] + #[zbus(allow_interactive_auth)] fn test_interactive_auth(&self) -> zbus::Result<()>; - #[dbus_proxy(property)] + #[zbus(property)] fn emits_changed_default(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn set_emits_changed_default(&self, count: u32) -> zbus::Result<()>; - #[dbus_proxy(property(emits_changed_signal = "true"))] + #[zbus(property(emits_changed_signal = "true"))] fn emits_changed_true(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn set_emits_changed_true(&self, count: u32) -> zbus::Result<()>; - #[dbus_proxy(property(emits_changed_signal = "invalidates"))] + #[zbus(property(emits_changed_signal = "invalidates"))] fn emits_changed_invalidates(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn set_emits_changed_invalidates(&self, count: u32) -> zbus::Result<()>; - #[dbus_proxy(property(emits_changed_signal = "const"))] + #[zbus(property(emits_changed_signal = "const"))] fn emits_changed_const(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn set_emits_changed_const(&self, count: u32) -> zbus::Result<()>; - #[dbus_proxy(property(emits_changed_signal = "false"))] + #[zbus(property(emits_changed_signal = "false"))] fn emits_changed_false(&self) -> zbus::Result; - #[dbus_proxy(property)] + #[zbus(property)] fn set_emits_changed_false(&self, count: u32) -> zbus::Result<()>; } @@ -189,14 +190,14 @@ impl MyIfaceImpl { /// Custom D-Bus error type. #[derive(Debug, DBusError)] -#[dbus_error(prefix = "org.freedesktop.MyIface.Error")] +#[zbus(prefix = "org.freedesktop.MyIface.Error")] enum MyIfaceError { SomethingWentWrong(String), - #[dbus_error(zbus_error)] + #[zbus(zbus)] ZBus(zbus::Error), } -#[dbus_interface(interface = "org.freedesktop.MyIface")] +#[interface(interface = "org.freedesktop.MyIface")] impl MyIfaceImpl { #[instrument] async fn ping(&mut self, #[zbus(signal_context)] ctxt: SignalContext<'_>) -> u32 { @@ -261,7 +262,7 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(out_args("foo", "bar"))] + #[zbus(out_args("foo", "bar"))] fn test_multi_ret(&self) -> zbus::fdo::Result<(i32, String)> { debug!("`TestMultiRet` called."); Ok((42, String::from("Meaning of life"))) @@ -290,7 +291,7 @@ impl MyIfaceImpl { Ok(response) } - #[dbus_interface(signal)] + #[zbus(signal)] async fn test_response_notified(ctxt: SignalContext<'_>) -> zbus::Result<()>; #[instrument] @@ -342,7 +343,7 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn set_count(&mut self, val: u32) -> zbus::fdo::Result<()> { debug!("`Count` setter called."); if val == 42 { @@ -353,21 +354,21 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn count(&self) -> u32 { debug!("`Count` getter called."); self.count } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] async fn hash_map(&self) -> HashMap { debug!("`HashMap` getter called."); self.test_hashmap_return().await.unwrap() } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] async fn fail_property(&self) -> zbus::fdo::Result { Err(zbus::fdo::Error::UnknownProperty( "FailProperty".to_string(), @@ -375,14 +376,14 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn optional_property(&self) -> Optional { debug!("`OptionalAsProp` getter called."); Some(42).into() } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn address_data(&self) -> IP4Adress { debug!("`AddressData` getter called."); IP4Adress { @@ -392,7 +393,7 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn set_address_data(&self, addr: IP4Adress) { debug!("`AddressData` setter called with {:?}", addr); } @@ -400,7 +401,7 @@ impl MyIfaceImpl { // On the bus, this should return the same value as address_data above. We want to test if // this works both ways. #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn address_data2(&self) -> HashMap { debug!("`AddressData2` getter called."); let mut map = HashMap::new(); @@ -414,19 +415,19 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn str_prop(&self) -> String { "Hello".to_string() } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn set_str_prop(&self, str_prop: &str) { debug!("`SetStrRef` called with {:?}", str_prop); } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn ref_prop(&self) -> RefType<'_> { RefType { field1: "Hello".into(), @@ -434,7 +435,7 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn set_ref_prop(&self, ref_type: RefType<'_>) { debug!("`SetRefType` called with {:?}", ref_type); } @@ -469,18 +470,18 @@ impl MyIfaceImpl { .contains(zbus::message::Flags::AllowInteractiveAuth)); } - #[dbus_interface(signal)] + #[zbus(signal)] async fn alert_count(ctxt: &SignalContext<'_>, val: u32) -> zbus::Result<()>; #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn emits_changed_default(&self) -> u32 { debug!("`EmitsChangedDefault` getter called."); self.emits_changed_default } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn set_emits_changed_default(&mut self, val: u32) -> zbus::fdo::Result<()> { debug!("`EmitsChangedDefault` setter called."); self.emits_changed_default = val; @@ -488,14 +489,14 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property(emits_changed_signal = "true"))] + #[zbus(property(emits_changed_signal = "true"))] fn emits_changed_true(&self) -> u32 { debug!("`EmitsChangedTrue` getter called."); self.emits_changed_true } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn set_emits_changed_true(&mut self, val: u32) -> zbus::fdo::Result<()> { debug!("`EmitsChangedTrue` setter called."); self.emits_changed_true = val; @@ -503,14 +504,14 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property(emits_changed_signal = "invalidates"))] + #[zbus(property(emits_changed_signal = "invalidates"))] fn emits_changed_invalidates(&self) -> u32 { debug!("`EmitsChangedInvalidates` getter called."); self.emits_changed_invalidates } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn set_emits_changed_invalidates(&mut self, val: u32) -> zbus::fdo::Result<()> { debug!("`EmitsChangedInvalidates` setter called."); self.emits_changed_invalidates = val; @@ -518,14 +519,14 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property(emits_changed_signal = "const"))] + #[zbus(property(emits_changed_signal = "const"))] fn emits_changed_const(&self) -> u32 { debug!("`EmitsChangedConst` getter called."); self.emits_changed_const } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn set_emits_changed_const(&mut self, val: u32) -> zbus::fdo::Result<()> { debug!("`EmitsChangedConst` setter called."); self.emits_changed_const = val; @@ -533,14 +534,14 @@ impl MyIfaceImpl { } #[instrument] - #[dbus_interface(property(emits_changed_signal = "false"))] + #[zbus(property(emits_changed_signal = "false"))] fn emits_changed_false(&self) -> u32 { debug!("`EmitsChangedFalse` getter called."); self.emits_changed_false } #[instrument] - #[dbus_interface(property)] + #[zbus(property)] fn set_emits_changed_false(&mut self, val: u32) -> zbus::fdo::Result<()> { debug!("`EmitsChangedFalse` setter called."); self.emits_changed_false = val; diff --git a/zbus_macros/iface.txt b/zbus_macros/iface.txt new file mode 100644 index 000000000..f294d6ab0 --- /dev/null +++ b/zbus_macros/iface.txt @@ -0,0 +1,6061 @@ +mod iface { + use proc_macro2::TokenStream; + use quote::{format_ident, quote}; + use std::collections::BTreeMap; + use syn::{ + self, parse_quote, punctuated::Punctuated, spanned::Spanned, + AngleBracketedGenericArguments, Attribute, AttributeArgs, Error, FnArg, + GenericArgument, ImplItem, ImplItemMethod, ItemImpl, Lit::Str, Meta, + Meta::NameValue, MetaList, MetaNameValue, NestedMeta, PatType, PathArguments, + ReturnType, Signature, Token, Type, TypePath, + }; + use zvariant_utils::{case, def_attrs, macros::AttrParse, old_new}; + use crate::utils::*; + const DEPRECATION_WARNING: &str = "The `#[dbus_interface(...)]` attribute of interface has been deprecated in favor of `#[zbus(...)]`."; + pub mod old { + use super::def_attrs; + static ALLOWED_ATTRS: &[&'static str] = &[ + "interface", + "name", + "name", + "signal", + "property", + "out_args", + ]; + pub struct TraitAttributes { + pub interface: ::std::option::Option<::std::string::String>, + pub name: ::std::option::Option<::std::string::String>, + } + #[automatically_derived] + impl ::core::default::Default for TraitAttributes { + #[inline] + fn default() -> TraitAttributes { + TraitAttributes { + interface: ::core::default::Default::default(), + name: ::core::default::Default::default(), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for TraitAttributes { + #[inline] + fn clone(&self) -> TraitAttributes { + TraitAttributes { + interface: ::core::clone::Clone::clone(&self.interface), + name: ::core::clone::Clone::clone(&self.name), + } + } + } + #[automatically_derived] + impl ::core::fmt::Debug for TraitAttributes { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::fmt::Formatter::debug_struct_field2_finish( + f, + "TraitAttributes", + "interface", + &self.interface, + "name", + &&self.name, + ) + } + } + impl ::zvariant_utils::macros::AttrParse for TraitAttributes { + fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + self.parse_meta(meta) + } + fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + Self: Sized, + { + Self::parse_nested_metas(iter) + } + fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result + where + Self: Sized, + { + Self::parse(attrs) + } + } + impl TraitAttributes { + pub fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + use ::syn::spanned::Spanned; + if let ::std::option::Option::Some(value) + = ::zvariant_utils::macros::match_attribute_with_str_value( + meta, + "interface", + )? { + if self.interface.is_none() { + self.interface = ::std::option::Option::Some(value.value()); + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `interface` attribute", + ), + ); + } + } + if let ::std::option::Option::Some(value) + = ::zvariant_utils::macros::match_attribute_with_str_value( + meta, + "name", + )? { + if self.name.is_none() { + self.name = ::std::option::Option::Some(value.value()); + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new(meta.span(), "duplicate `name` attribute"), + ); + } + } + let is_valid_attr = ALLOWED_ATTRS + .iter() + .any(|attr| meta.path().is_ident(attr)); + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + if is_valid_attr { + { + let res = ::alloc::fmt::format( + format_args!( + "attribute `{0}` is not allowed on trait", meta.path() + .get_ident().unwrap() + ), + ); + res + } + } else { + { + let res = ::alloc::fmt::format( + format_args!( + "unknown attribute `{0}`", meta.path().get_ident().unwrap() + ), + ); + res + } + }, + ), + ); + } + pub fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + { + let mut parsed = TraitAttributes::default(); + for nested_meta in iter { + match nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `dbus_interface` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + pub fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result { + let mut parsed = TraitAttributes::default(); + for nested_meta in ::zvariant_utils::macros::iter_meta_lists( + attrs, + "dbus_interface", + )? { + match &nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `dbus_interface` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + } + pub struct MethodAttributes { + pub name: ::std::option::Option<::std::string::String>, + pub signal: bool, + pub property: bool, + pub out_args: ::std::option::Option<::std::vec::Vec<::std::string::String>>, + } + #[automatically_derived] + impl ::core::default::Default for MethodAttributes { + #[inline] + fn default() -> MethodAttributes { + MethodAttributes { + name: ::core::default::Default::default(), + signal: ::core::default::Default::default(), + property: ::core::default::Default::default(), + out_args: ::core::default::Default::default(), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for MethodAttributes { + #[inline] + fn clone(&self) -> MethodAttributes { + MethodAttributes { + name: ::core::clone::Clone::clone(&self.name), + signal: ::core::clone::Clone::clone(&self.signal), + property: ::core::clone::Clone::clone(&self.property), + out_args: ::core::clone::Clone::clone(&self.out_args), + } + } + } + #[automatically_derived] + impl ::core::fmt::Debug for MethodAttributes { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::fmt::Formatter::debug_struct_field4_finish( + f, + "MethodAttributes", + "name", + &self.name, + "signal", + &self.signal, + "property", + &self.property, + "out_args", + &&self.out_args, + ) + } + } + impl ::zvariant_utils::macros::AttrParse for MethodAttributes { + fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + self.parse_meta(meta) + } + fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + Self: Sized, + { + Self::parse_nested_metas(iter) + } + fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result + where + Self: Sized, + { + Self::parse(attrs) + } + } + impl MethodAttributes { + pub fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + use ::syn::spanned::Spanned; + if let ::std::option::Option::Some(value) + = ::zvariant_utils::macros::match_attribute_with_str_value( + meta, + "name", + )? { + if self.name.is_none() { + self.name = ::std::option::Option::Some(value.value()); + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new(meta.span(), "duplicate `name` attribute"), + ); + } + } + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "signal", + )? { + if !self.signal { + self.signal = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `signal` attribute", + ), + ); + } + } + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "property", + )? { + if !self.property { + self.property = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `property` attribute", + ), + ); + } + } + if let Some(list) + = ::zvariant_utils::macros::match_attribute_with_str_list_value( + meta, + "out_args", + )? { + if self.out_args.is_none() { + self.out_args = Some(list); + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `out_args` attribute", + ), + ); + } + } + let is_valid_attr = ALLOWED_ATTRS + .iter() + .any(|attr| meta.path().is_ident(attr)); + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + if is_valid_attr { + { + let res = ::alloc::fmt::format( + format_args!( + "attribute `{0}` is not allowed on method", meta.path() + .get_ident().unwrap() + ), + ); + res + } + } else { + { + let res = ::alloc::fmt::format( + format_args!( + "unknown attribute `{0}`", meta.path().get_ident().unwrap() + ), + ); + res + } + }, + ), + ); + } + pub fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + { + let mut parsed = MethodAttributes::default(); + for nested_meta in iter { + match nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `dbus_interface` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + pub fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result { + let mut parsed = MethodAttributes::default(); + for nested_meta in ::zvariant_utils::macros::iter_meta_lists( + attrs, + "dbus_interface", + )? { + match &nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `dbus_interface` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + } + mod arg_attrs { + use super::def_attrs; + static ALLOWED_ATTRS: &[&'static str] = &[ + "object_server", + "connection", + "header", + "signal_context", + ]; + pub struct ArgAttributes { + pub object_server: bool, + pub connection: bool, + pub header: bool, + pub signal_context: bool, + } + #[automatically_derived] + impl ::core::default::Default for ArgAttributes { + #[inline] + fn default() -> ArgAttributes { + ArgAttributes { + object_server: ::core::default::Default::default(), + connection: ::core::default::Default::default(), + header: ::core::default::Default::default(), + signal_context: ::core::default::Default::default(), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for ArgAttributes { + #[inline] + fn clone(&self) -> ArgAttributes { + ArgAttributes { + object_server: ::core::clone::Clone::clone(&self.object_server), + connection: ::core::clone::Clone::clone(&self.connection), + header: ::core::clone::Clone::clone(&self.header), + signal_context: ::core::clone::Clone::clone(&self.signal_context), + } + } + } + #[automatically_derived] + impl ::core::fmt::Debug for ArgAttributes { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::fmt::Formatter::debug_struct_field4_finish( + f, + "ArgAttributes", + "object_server", + &self.object_server, + "connection", + &self.connection, + "header", + &self.header, + "signal_context", + &&self.signal_context, + ) + } + } + impl ::zvariant_utils::macros::AttrParse for ArgAttributes { + fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + self.parse_meta(meta) + } + fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + Self: Sized, + { + Self::parse_nested_metas(iter) + } + fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result + where + Self: Sized, + { + Self::parse(attrs) + } + } + impl ArgAttributes { + pub fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + use ::syn::spanned::Spanned; + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "object_server", + )? { + if !self.object_server { + self.object_server = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `object_server` attribute", + ), + ); + } + } + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "connection", + )? { + if !self.connection { + self.connection = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `connection` attribute", + ), + ); + } + } + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "header", + )? { + if !self.header { + self.header = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `header` attribute", + ), + ); + } + } + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "signal_context", + )? { + if !self.signal_context { + self.signal_context = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `signal_context` attribute", + ), + ); + } + } + let is_valid_attr = ALLOWED_ATTRS + .iter() + .any(|attr| meta.path().is_ident(attr)); + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + if is_valid_attr { + { + let res = ::alloc::fmt::format( + format_args!( + "attribute `{0}` is not allowed on argument", meta.path() + .get_ident().unwrap() + ), + ); + res + } + } else { + { + let res = ::alloc::fmt::format( + format_args!( + "unknown attribute `{0}`", meta.path().get_ident().unwrap() + ), + ); + res + } + }, + ), + ); + } + pub fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + { + let mut parsed = ArgAttributes::default(); + for nested_meta in iter { + match nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `dbus_interface` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + pub fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result { + let mut parsed = ArgAttributes::default(); + for nested_meta in ::zvariant_utils::macros::iter_meta_lists( + attrs, + "dbus_interface", + )? { + match &nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `dbus_interface` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + } + } + pub use arg_attrs::ArgAttributes; + } + static ALLOWED_ATTRS: &[&'static str] = &[ + "interface", + "name", + "name", + "signal", + "property", + "out_args", + ]; + pub struct TraitAttributes { + pub interface: ::std::option::Option<::std::string::String>, + pub name: ::std::option::Option<::std::string::String>, + } + #[automatically_derived] + impl ::core::default::Default for TraitAttributes { + #[inline] + fn default() -> TraitAttributes { + TraitAttributes { + interface: ::core::default::Default::default(), + name: ::core::default::Default::default(), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for TraitAttributes { + #[inline] + fn clone(&self) -> TraitAttributes { + TraitAttributes { + interface: ::core::clone::Clone::clone(&self.interface), + name: ::core::clone::Clone::clone(&self.name), + } + } + } + #[automatically_derived] + impl ::core::fmt::Debug for TraitAttributes { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::fmt::Formatter::debug_struct_field2_finish( + f, + "TraitAttributes", + "interface", + &self.interface, + "name", + &&self.name, + ) + } + } + impl ::zvariant_utils::macros::AttrParse for TraitAttributes { + fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + self.parse_meta(meta) + } + fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + Self: Sized, + { + Self::parse_nested_metas(iter) + } + fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result + where + Self: Sized, + { + Self::parse(attrs) + } + } + impl TraitAttributes { + pub fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + use ::syn::spanned::Spanned; + if let ::std::option::Option::Some(value) + = ::zvariant_utils::macros::match_attribute_with_str_value( + meta, + "interface", + )? { + if self.interface.is_none() { + self.interface = ::std::option::Option::Some(value.value()); + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new(meta.span(), "duplicate `interface` attribute"), + ); + } + } + if let ::std::option::Option::Some(value) + = ::zvariant_utils::macros::match_attribute_with_str_value( + meta, + "name", + )? { + if self.name.is_none() { + self.name = ::std::option::Option::Some(value.value()); + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new(meta.span(), "duplicate `name` attribute"), + ); + } + } + let is_valid_attr = ALLOWED_ATTRS + .iter() + .any(|attr| meta.path().is_ident(attr)); + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + if is_valid_attr { + { + let res = ::alloc::fmt::format( + format_args!( + "attribute `{0}` is not allowed on trait", meta.path() + .get_ident().unwrap() + ), + ); + res + } + } else { + { + let res = ::alloc::fmt::format( + format_args!( + "unknown attribute `{0}`", meta.path().get_ident().unwrap() + ), + ); + res + } + }, + ), + ); + } + pub fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + { + let mut parsed = TraitAttributes::default(); + for nested_meta in iter { + match nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `zbus` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + pub fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result { + let mut parsed = TraitAttributes::default(); + for nested_meta in ::zvariant_utils::macros::iter_meta_lists( + attrs, + "zbus", + )? { + match &nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `zbus` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + } + pub struct PropertyAttributes { + pub emits_changed_signal: ::std::option::Option<::std::string::String>, + } + #[automatically_derived] + impl ::core::default::Default for PropertyAttributes { + #[inline] + fn default() -> PropertyAttributes { + PropertyAttributes { + emits_changed_signal: ::core::default::Default::default(), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for PropertyAttributes { + #[inline] + fn clone(&self) -> PropertyAttributes { + PropertyAttributes { + emits_changed_signal: ::core::clone::Clone::clone( + &self.emits_changed_signal, + ), + } + } + } + #[automatically_derived] + impl ::core::fmt::Debug for PropertyAttributes { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::fmt::Formatter::debug_struct_field1_finish( + f, + "PropertyAttributes", + "emits_changed_signal", + &&self.emits_changed_signal, + ) + } + } + impl ::zvariant_utils::macros::AttrParse for PropertyAttributes { + fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + self.parse_meta(meta) + } + fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + Self: Sized, + { + Self::parse_nested_metas(iter) + } + fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result + where + Self: Sized, + { + Self::parse(attrs) + } + } + impl PropertyAttributes { + pub fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + use ::syn::spanned::Spanned; + if let ::std::option::Option::Some(value) + = ::zvariant_utils::macros::match_attribute_with_str_value( + meta, + "emits_changed_signal", + )? { + if self.emits_changed_signal.is_none() { + self + .emits_changed_signal = ::std::option::Option::Some( + value.value(), + ); + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `emits_changed_signal` attribute", + ), + ); + } + } + let is_valid_attr = ALLOWED_ATTRS + .iter() + .any(|attr| meta.path().is_ident(attr)); + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + if is_valid_attr { + { + let res = ::alloc::fmt::format( + format_args!( + "attribute `{0}` is not allowed on property", meta.path() + .get_ident().unwrap() + ), + ); + res + } + } else { + { + let res = ::alloc::fmt::format( + format_args!( + "unknown attribute `{0}`", meta.path().get_ident().unwrap() + ), + ); + res + } + }, + ), + ); + } + pub fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + { + let mut parsed = PropertyAttributes::default(); + for nested_meta in iter { + match nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `property` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + pub fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result { + let mut parsed = PropertyAttributes::default(); + for nested_meta in ::zvariant_utils::macros::iter_meta_lists( + attrs, + "property", + )? { + match &nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `property` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + } + pub struct MethodAttributes { + pub name: ::std::option::Option<::std::string::String>, + pub signal: bool, + pub property: ::std::option::Option, + pub out_args: ::std::option::Option<::std::vec::Vec<::std::string::String>>, + } + #[automatically_derived] + impl ::core::default::Default for MethodAttributes { + #[inline] + fn default() -> MethodAttributes { + MethodAttributes { + name: ::core::default::Default::default(), + signal: ::core::default::Default::default(), + property: ::core::default::Default::default(), + out_args: ::core::default::Default::default(), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for MethodAttributes { + #[inline] + fn clone(&self) -> MethodAttributes { + MethodAttributes { + name: ::core::clone::Clone::clone(&self.name), + signal: ::core::clone::Clone::clone(&self.signal), + property: ::core::clone::Clone::clone(&self.property), + out_args: ::core::clone::Clone::clone(&self.out_args), + } + } + } + #[automatically_derived] + impl ::core::fmt::Debug for MethodAttributes { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::fmt::Formatter::debug_struct_field4_finish( + f, + "MethodAttributes", + "name", + &self.name, + "signal", + &self.signal, + "property", + &self.property, + "out_args", + &&self.out_args, + ) + } + } + impl ::zvariant_utils::macros::AttrParse for MethodAttributes { + fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + self.parse_meta(meta) + } + fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + Self: Sized, + { + Self::parse_nested_metas(iter) + } + fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result + where + Self: Sized, + { + Self::parse(attrs) + } + } + impl MethodAttributes { + pub fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + use ::syn::spanned::Spanned; + if let ::std::option::Option::Some(value) + = ::zvariant_utils::macros::match_attribute_with_str_value( + meta, + "name", + )? { + if self.name.is_none() { + self.name = ::std::option::Option::Some(value.value()); + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new(meta.span(), "duplicate `name` attribute"), + ); + } + } + if ::zvariant_utils::macros::match_attribute_without_value(meta, "signal")? { + if !self.signal { + self.signal = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new(meta.span(), "duplicate `signal` attribute"), + ); + } + } + if meta.path().is_ident("property") { + return if self.property.is_none() { + match meta { + ::syn::Meta::List(meta) => { + self + .property = ::std::option::Option::Some( + PropertyAttributes::parse_nested_metas(meta.nested.iter())?, + ); + ::std::result::Result::Ok(()) + } + ::syn::Meta::Path(_) => { + self + .property = ::std::option::Option::Some( + PropertyAttributes::default(), + ); + ::std::result::Result::Ok(()) + } + ::syn::Meta::NameValue(_) => { + Err( + ::syn::Error::new( + meta.span(), + { + let res = ::alloc::fmt::format( + format_args!( + "attribute `property` must be either a list or a path" + ), + ); + res + }, + ), + ) + } + } + } else { + ::std::result::Result::Err( + ::syn::Error::new(meta.span(), "duplicate `property` attribute"), + ) + }; + } + if let Some(list) + = ::zvariant_utils::macros::match_attribute_with_str_list_value( + meta, + "out_args", + )? { + if self.out_args.is_none() { + self.out_args = Some(list); + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new(meta.span(), "duplicate `out_args` attribute"), + ); + } + } + let is_valid_attr = ALLOWED_ATTRS + .iter() + .any(|attr| meta.path().is_ident(attr)); + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + if is_valid_attr { + { + let res = ::alloc::fmt::format( + format_args!( + "attribute `{0}` is not allowed on method", meta.path() + .get_ident().unwrap() + ), + ); + res + } + } else { + { + let res = ::alloc::fmt::format( + format_args!( + "unknown attribute `{0}`", meta.path().get_ident().unwrap() + ), + ); + res + } + }, + ), + ); + } + pub fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + { + let mut parsed = MethodAttributes::default(); + for nested_meta in iter { + match nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `zbus` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + pub fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result { + let mut parsed = MethodAttributes::default(); + for nested_meta in ::zvariant_utils::macros::iter_meta_lists( + attrs, + "zbus", + )? { + match &nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `zbus` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + } + mod arg_attrs { + use zvariant_utils::def_attrs; + static ALLOWED_ATTRS: &[&'static str] = &[ + "object_server", + "connection", + "header", + "signal_context", + ]; + pub struct ArgAttributes { + pub object_server: bool, + pub connection: bool, + pub header: bool, + pub signal_context: bool, + } + #[automatically_derived] + impl ::core::default::Default for ArgAttributes { + #[inline] + fn default() -> ArgAttributes { + ArgAttributes { + object_server: ::core::default::Default::default(), + connection: ::core::default::Default::default(), + header: ::core::default::Default::default(), + signal_context: ::core::default::Default::default(), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for ArgAttributes { + #[inline] + fn clone(&self) -> ArgAttributes { + ArgAttributes { + object_server: ::core::clone::Clone::clone(&self.object_server), + connection: ::core::clone::Clone::clone(&self.connection), + header: ::core::clone::Clone::clone(&self.header), + signal_context: ::core::clone::Clone::clone(&self.signal_context), + } + } + } + #[automatically_derived] + impl ::core::fmt::Debug for ArgAttributes { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::fmt::Formatter::debug_struct_field4_finish( + f, + "ArgAttributes", + "object_server", + &self.object_server, + "connection", + &self.connection, + "header", + &self.header, + "signal_context", + &&self.signal_context, + ) + } + } + impl ::zvariant_utils::macros::AttrParse for ArgAttributes { + fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + self.parse_meta(meta) + } + fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + Self: Sized, + { + Self::parse_nested_metas(iter) + } + fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result + where + Self: Sized, + { + Self::parse(attrs) + } + } + impl ArgAttributes { + pub fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()> { + use ::syn::spanned::Spanned; + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "object_server", + )? { + if !self.object_server { + self.object_server = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `object_server` attribute", + ), + ); + } + } + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "connection", + )? { + if !self.connection { + self.connection = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `connection` attribute", + ), + ); + } + } + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "header", + )? { + if !self.header { + self.header = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `header` attribute", + ), + ); + } + } + if ::zvariant_utils::macros::match_attribute_without_value( + meta, + "signal_context", + )? { + if !self.signal_context { + self.signal_context = true; + return Ok(()); + } else { + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + "duplicate `signal_context` attribute", + ), + ); + } + } + let is_valid_attr = ALLOWED_ATTRS + .iter() + .any(|attr| meta.path().is_ident(attr)); + return ::std::result::Result::Err( + ::syn::Error::new( + meta.span(), + if is_valid_attr { + { + let res = ::alloc::fmt::format( + format_args!( + "attribute `{0}` is not allowed on argument", meta.path() + .get_ident().unwrap() + ), + ); + res + } + } else { + { + let res = ::alloc::fmt::format( + format_args!( + "unknown attribute `{0}`", meta.path().get_ident().unwrap() + ), + ); + res + } + }, + ), + ); + } + pub fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + { + let mut parsed = ArgAttributes::default(); + for nested_meta in iter { + match nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `zbus` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + pub fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result { + let mut parsed = ArgAttributes::default(); + for nested_meta in ::zvariant_utils::macros::iter_meta_lists( + attrs, + "zbus", + )? { + match &nested_meta { + ::syn::NestedMeta::Meta(meta) => parsed.parse_meta(meta), + ::syn::NestedMeta::Lit(lit) => { + ::std::result::Result::Err( + ::syn::Error::new( + lit.span(), + "attribute `zbus` does not support literals in meta lists", + ), + ) + } + }?; + } + Ok(parsed) + } + } + } + pub use arg_attrs::ArgAttributes; + pub enum ArgAttrs { + Old(old::ArgAttributes), + New(ArgAttributes), + } + impl From for ArgAttrs { + fn from(old: old::ArgAttributes) -> Self { + Self::Old(old) + } + } + impl From for ArgAttrs { + fn from(new: ArgAttributes) -> Self { + Self::New(new) + } + } + pub enum TraitAttrs { + Old(old::TraitAttributes), + New(TraitAttributes), + } + impl From for TraitAttrs { + fn from(old: old::TraitAttributes) -> Self { + Self::Old(old) + } + } + impl From for TraitAttrs { + fn from(new: TraitAttributes) -> Self { + Self::New(new) + } + } + pub enum MethodAttrs { + Old(old::MethodAttributes), + New(MethodAttributes), + } + impl From for MethodAttrs { + fn from(old: old::MethodAttributes) -> Self { + Self::Old(old) + } + } + impl From for MethodAttrs { + fn from(new: MethodAttributes) -> Self { + Self::New(new) + } + } + struct Property<'a> { + read: bool, + write: bool, + emits_changed_signal: PropertyEmitsChangedSignal, + ty: Option<&'a Type>, + doc_comments: TokenStream, + } + #[automatically_derived] + impl<'a> ::core::fmt::Debug for Property<'a> { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::fmt::Formatter::debug_struct_field5_finish( + f, + "Property", + "read", + &self.read, + "write", + &self.write, + "emits_changed_signal", + &self.emits_changed_signal, + "ty", + &self.ty, + "doc_comments", + &&self.doc_comments, + ) + } + } + impl<'a> Property<'a> { + fn new() -> Self { + Self { + read: false, + write: false, + emits_changed_signal: PropertyEmitsChangedSignal::True, + ty: None, + doc_comments: ::quote::__private::TokenStream::new(), + } + } + } + enum MethodType { + Signal, + Property(PropertyType), + Other, + } + #[automatically_derived] + impl ::core::marker::StructuralPartialEq for MethodType {} + #[automatically_derived] + impl ::core::cmp::PartialEq for MethodType { + #[inline] + fn eq(&self, other: &MethodType) -> bool { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + __self_tag == __arg1_tag + && match (self, other) { + (MethodType::Property(__self_0), MethodType::Property(__arg1_0)) => { + *__self_0 == *__arg1_0 + } + _ => true, + } + } + } + enum PropertyType { + Inputs, + NoInputs, + } + #[automatically_derived] + impl ::core::marker::StructuralPartialEq for PropertyType {} + #[automatically_derived] + impl ::core::cmp::PartialEq for PropertyType { + #[inline] + fn eq(&self, other: &PropertyType) -> bool { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + __self_tag == __arg1_tag + } + } + struct MethodInfo { + /// The type of method being parsed + method_type: MethodType, + /// Whether the method has inputs + has_inputs: bool, + /// Whether the method is async + is_async: bool, + /// Doc comments on the methods + doc_comments: TokenStream, + /// Whether self is passed as mutable to the method + is_mut: bool, + /// The await to append to method calls + method_await: TokenStream, + /// The typed inputs passed to the method + typed_inputs: Vec, + /// The method arguments' introspection + intro_args: TokenStream, + /// Whether the output type is a Result + is_result_output: bool, + /// Code block to deserialize arguments from zbus message + args_from_msg: TokenStream, + /// Names of all arguments to the method + args_names: TokenStream, + /// Code stream to match on the reply of the method call + reply: TokenStream, + /// The signal context object argument + signal_context_arg: Option, + /// The name of the method (setters are stripped of set_ prefix) + member_name: String, + } + impl MethodInfo { + fn new + AttrParse>( + zbus: &TokenStream, + method: &ImplItemMethod, + attrs: &MethodAttrs, + cfg_attrs: &[&Attribute], + ) -> syn::Result { + let is_async = method.sig.asyncness.is_some(); + let Signature { ident, inputs, output, .. } = &method.sig; + let docs = get_doc_attrs(&method.attrs) + .iter() + .filter_map(|attr| { + if let Ok(NameValue(MetaNameValue { lit: Str(s), .. })) + = attr.parse_meta() + { + Some(s.value()) + } else { + None + } + }) + .collect(); + let doc_comments = to_xml_docs(docs); + let (is_property, is_signal, out_args, attrs_name) = match attrs { + MethodAttrs::Old(old) => { + (old.property, old.signal, old.out_args, old.name) + } + MethodAttrs::New(new) => { + (new.property, new.signal, new.out_args, new.name) + } + }; + if !(!is_property || !is_signal) { + ::core::panicking::panic("assertion failed: !is_property || !is_signal") + } + let has_inputs = inputs.len() > 1; + let is_mut = if let FnArg::Receiver(r) + = inputs + .first() + .ok_or_else(|| Error::new_spanned(ident, "not &self method"))? + { + r.mutability.is_some() + } else if is_signal { + false + } else { + return Err(Error::new_spanned(method, "missing receiver")); + }; + if is_signal && !is_async { + return Err(Error::new_spanned(method, "signals must be async")); + } + let method_await = if is_async { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + _s + } + } else { + ::quote::__private::TokenStream::new() + }; + let mut typed_inputs = inputs + .iter() + .filter_map(typed_arg) + .cloned() + .collect::>(); + let signal_context_arg: Option = if is_signal { + if typed_inputs.is_empty() { + return Err( + Error::new_spanned( + inputs, + "Expected a `&zbus::object_server::SignalContext<'_> argument", + ), + ); + } + Some(typed_inputs.remove(0)) + } else { + None + }; + let mut intro_args = ::quote::__private::TokenStream::new(); + intro_args + .extend(introspect_input_args(&typed_inputs, is_signal, cfg_attrs)); + let is_result_output = introspect_add_output_args( + &mut intro_args, + output, + out_args, + cfg_attrs, + )?; + let (args_from_msg, args_names) = get_args_from_inputs::< + A, + >(&typed_inputs, zbus)?; + let reply = if is_result_output { + let ret = { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "r"); + _s + }; + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_ident(&mut _s, "reply"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "r"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_ident(&mut _s, "c"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "reply"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "m"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::ToTokens::to_tokens(&ret, &mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "hdr"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "m"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "header"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_ident(&mut _s, "c"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "reply_dbus_error"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "hdr"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + _s + }, + ); + _s + }, + ); + _s + } + } else { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "c"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "reply"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "m"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "reply"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + _s + } + }; + let member_name = attrs_name + .clone() + .unwrap_or_else(|| { + let mut name = ident.to_string(); + if is_property && has_inputs { + if !name.starts_with("set_") { + ::core::panicking::panic( + "assertion failed: name.starts_with(\"set_\")", + ) + } + name = name[4..].to_string(); + } + pascal_case(&name) + }); + let method_type = if is_signal { + MethodType::Signal + } else if is_property { + if has_inputs { + MethodType::Property(PropertyType::Inputs) + } else { + MethodType::Property(PropertyType::NoInputs) + } + } else { + MethodType::Other + }; + Ok(MethodInfo { + method_type, + has_inputs, + is_async, + doc_comments, + is_mut, + method_await, + typed_inputs, + signal_context_arg, + intro_args, + is_result_output, + args_from_msg, + args_names, + reply, + member_name, + }) + } + } + pub fn expand< + T: AttrParse + Into, + M: AttrParse + Into, + A: AttrParse + Into, + >(args: AttributeArgs, mut input: ItemImpl) -> syn::Result { + let zbus = zbus_path(); + let self_ty = &input.self_ty; + let mut properties = BTreeMap::new(); + let mut set_dispatch = ::quote::__private::TokenStream::new(); + let mut set_mut_dispatch = ::quote::__private::TokenStream::new(); + let mut get_dispatch = ::quote::__private::TokenStream::new(); + let mut get_all = ::quote::__private::TokenStream::new(); + let _call_dispatch = ::quote::__private::TokenStream::new(); + let _call_mut_dispatch = ::quote::__private::TokenStream::new(); + let mut call_dispatch = ::quote::__private::TokenStream::new(); + let mut call_mut_dispatch = ::quote::__private::TokenStream::new(); + let mut introspect = ::quote::__private::TokenStream::new(); + let mut generated_signals = ::quote::__private::TokenStream::new(); + let ty = match input.self_ty.as_ref() { + Type::Path(p) => { + &p + .path + .segments + .last() + .ok_or_else(|| Error::new_spanned(p, "Unsupported 'impl' type"))? + .ident + } + _ => return Err(Error::new_spanned(&input.self_ty, "Invalid type")), + }; + let iface_name = { + let (name, interface) = match T::parse_nested_metas(&args)?.into() { + TraitAttrs::New(new) => (new.name, new.interface), + TraitAttrs::Old(old) => { + { + ::std::io::_eprint(format_args!("{0}\n", DEPRECATION_WARNING)); + }; + (old.name, old.interface) + } + }; + match (name, interface) { + (Some(name), None) | (None, Some(name)) => name, + (None, None) => { + let res = ::alloc::fmt::format( + format_args!("org.freedesktop.{0}", ty), + ); + res + } + (Some(_), Some(_)) => { + return Err( + syn::Error::new( + input.span(), + "`name` and `interface` attributes should not be specified at the same time", + ), + ); + } + } + }; + let mut methods = ::alloc::vec::Vec::new(); + for method in &mut input.items { + let method = match method { + ImplItem::Method(m) => m, + _ => continue, + }; + let attrs = M::parse(&method.attrs)?.into(); + match attrs { + MethodAttrs::Old(_) => { + { + ::std::io::_eprint(format_args!("{0}\n", DEPRECATION_WARNING)); + }; + } + _ => {} + }; + method + .attrs + .retain(|attr| { + match ( + attr.path.is_ident("zbus"), + attr.path.is_ident("dbus_interface"), + ) { + (true, _) => false, + (_, true) => { + { + ::std::io::_eprint( + format_args!("{0}\n", DEPRECATION_WARNING), + ); + }; + false + } + _ => true, + } + }); + let cfg_attrs: Vec<_> = method + .attrs + .iter() + .filter(|a| a.path.is_ident("cfg")) + .collect(); + let method_info = MethodInfo::new::(&zbus, method, &attrs, &cfg_attrs)?; + let attr_property = match attrs { + MethodAttrs::Old(o) => o.property, + MethodAttrs::New(n) => n.property, + }; + if let Some(prop_attrs) = &attr_property { + if method_info.method_type + == MethodType::Property(PropertyType::NoInputs) + { + let emits_changed_signal = if let Some(s) + = &prop_attrs.emits_changed_signal + { + PropertyEmitsChangedSignal::parse(s, method.span())? + } else { + PropertyEmitsChangedSignal::True + }; + let mut property = Property::new(); + property.emits_changed_signal = emits_changed_signal; + properties.insert(method_info.member_name.to_string(), property); + } else if prop_attrs.emits_changed_signal.is_some() { + return Err( + syn::Error::new( + method.span(), + "`emits_changed_signal` cannot be specified on setters", + ), + ); + } + } + methods.push((method, method_info)); + } + for (method, method_info) in methods { + let cfg_attrs: Vec<_> = method + .attrs + .iter() + .filter(|a| a.path.is_ident("cfg")) + .collect(); + let MethodInfo { + method_type, + has_inputs, + is_async, + doc_comments, + is_mut, + method_await, + typed_inputs, + signal_context_arg, + intro_args, + is_result_output, + args_from_msg, + args_names, + reply, + member_name, + } = method_info; + let Signature { ident, inputs, output, .. } = &mut method.sig; + clean_input_args(inputs); + match method_type { + MethodType::Signal => { + introspect.extend(doc_comments); + introspect.extend(introspect_signal(&member_name, &intro_args)); + let signal_context = signal_context_arg.unwrap().pat; + method + .block = ::syn::parse_quote::parse({ + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&signal_context, &mut _s); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "connection"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "emit_signal"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&signal_context, &mut _s); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "destination"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&signal_context, &mut _s); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "path"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&self_ty, &mut _s); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Interface"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "name"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&args_names, &mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + _s + }, + ); + _s + }); + } + MethodType::Property(_) => { + let p = properties + .get_mut(&member_name) + .ok_or( + Error::new_spanned( + &member_name, + "Write-only properties aren't supported yet", + ), + )?; + let sk_member_name = case::snake_case(&member_name); + let prop_changed_method_name = ::quote::__private::mk_ident( + &{ + let res = ::alloc::fmt::format( + format_args!("{0}_changed", sk_member_name), + ); + res + }, + ::quote::__private::Option::None, + ); + let prop_invalidate_method_name = ::quote::__private::mk_ident( + &{ + let res = ::alloc::fmt::format( + format_args!("{0}_invalidate", sk_member_name), + ); + res + }, + ::quote::__private::Option::None, + ); + p.doc_comments.extend(doc_comments); + if has_inputs { + p.write = true; + let set_call = if is_result_output { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "val"); + _s + }, + ); + ::quote::ToTokens::to_tokens(&method_await, &mut _s); + _s + } + } else if is_async { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "export"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "futures_util"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "future"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "FutureExt"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "map"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "val"); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + _s + } + } else { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "val"); + _s + }, + ); + _s + }, + ); + _s + } + }; + let value_to_owned = { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zbus"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Value"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "try_to_owned"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "value"); + _s + }, + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "val"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zbus"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Value"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "from"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "val"); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "return"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Into"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "into"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Error"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Variant"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Into"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "into"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + _s + }, + ); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + _s + }, + ); + _s + }, + ); + _s + }; + let value_arg = match &*typed_inputs + .first() + .ok_or_else(|| Error::new_spanned( + &inputs, + "Expected a value argument", + ))? + .ty + { + Type::Reference(_) => { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "value"); + _s + } + Type::Path(path) => { + path + .path + .segments + .first() + .map(|segment| match &segment.arguments { + PathArguments::AngleBracketed(angled) => { + angled + .args + .first() + .filter(|arg| match arg { + GenericArgument::Lifetime(_) => true, + _ => false, + }) + .map(|_| { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zbus"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Value"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "try_clone"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "value"); + _s + }, + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "val"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_ident(&mut _s, "val"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "return"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Into"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "into"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Error"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Variant"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Into"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "into"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + _s + }, + ); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + _s + }, + ); + _s + }, + ); + _s + }) + .unwrap_or_else(|| value_to_owned.clone()) + } + _ => value_to_owned.clone(), + }) + .unwrap_or_else(|| value_to_owned.clone()) + } + _ => value_to_owned, + }; + let prop_changed_method = match p.emits_changed_signal { + PropertyEmitsChangedSignal::True => { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens( + &prop_changed_method_name, + &mut _s, + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "signal_context"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "map"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_or(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_or(&mut _s); + ::quote::__private::push_ident(&mut _s, "set_result"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "map_err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "Into"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "into"); + _s + }, + ); + _s + }, + ); + _s + } + PropertyEmitsChangedSignal::Invalidates => { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens( + &prop_invalidate_method_name, + &mut _s, + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "signal_context"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "map"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_or(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_or(&mut _s); + ::quote::__private::push_ident(&mut _s, "set_result"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "map_err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "Into"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "into"); + _s + }, + ); + _s + }, + ); + _s + } + PropertyEmitsChangedSignal::False + | PropertyEmitsChangedSignal::Const => { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + _s + }, + ); + _s + }, + ); + _s + } + }; + let do_set = { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "value"); + ::quote::__private::push_eq(&mut _s); + ::quote::ToTokens::to_tokens(&value_arg, &mut _s); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "TryInto"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "try_into"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "value"); + _s + }, + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "val"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::ToTokens::to_tokens(&set_call, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "set_result"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::ToTokens::to_tokens(&prop_changed_method, &mut _s); + ::quote::__private::push_ident(&mut _s, "e"); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_ident(&mut _s, "e"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Into"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "into"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Error"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Variant"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Into"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "into"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + _s + }, + ); + _s + }, + ); + _s + }, + ); + _s + }; + if is_mut { + let q = { + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut cfg_attrs, i) = cfg_attrs.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let cfg_attrs = match cfg_attrs.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + ::quote::ToTokens::to_tokens(&cfg_attrs, &mut _s); + } + } + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Some"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "move"); + ::quote::__private::push_or_or(&mut _s); + ::quote::__private::push_ident(&mut _s, "async"); + ::quote::__private::push_ident(&mut _s, "move"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&do_set, &mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + _s + }, + ); + _s + }, + ); + _s + }; + set_mut_dispatch.extend(q); + let q = { + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut cfg_attrs, i) = cfg_attrs.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let cfg_attrs = match cfg_attrs.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + ::quote::ToTokens::to_tokens(&cfg_attrs, &mut _s); + } + } + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "RequiresMut"); + ::quote::__private::push_comma(&mut _s); + _s + }; + set_dispatch.extend(q); + } else { + let q = { + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut cfg_attrs, i) = cfg_attrs.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let cfg_attrs = match cfg_attrs.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + ::quote::ToTokens::to_tokens(&cfg_attrs, &mut _s); + } + } + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Async"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "boxed"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Box"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "pin"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "async"); + ::quote::__private::push_ident(&mut _s, "move"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&do_set, &mut _s); + _s + }, + ); + _s + }, + ); + _s + }, + ); + _s + }, + ); + _s + }; + set_dispatch.extend(q); + } + } else { + let is_fallible_property = is_result_output; + p.ty = Some(get_property_type(output)?); + p.read = true; + let value_convert = { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "OwnedValue"); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "TryFrom"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "try_from"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Value"); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "From"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "from"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "value"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "map_err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_or(&mut _s); + ::quote::__private::push_ident(&mut _s, "e"); + ::quote::__private::push_or(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Error"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Failed"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "to_string"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + _s + }, + ); + _s + }, + ); + _s + }; + let inner = if is_fallible_property { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::ToTokens::to_tokens(&method_await, &mut _s); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "and_then"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_or(&mut _s); + ::quote::__private::push_ident(&mut _s, "value"); + ::quote::__private::push_or(&mut _s); + ::quote::ToTokens::to_tokens(&value_convert, &mut _s); + _s + }, + ); + _s + } + } else { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "value"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::ToTokens::to_tokens(&method_await, &mut _s); + ::quote::__private::push_semi(&mut _s); + ::quote::ToTokens::to_tokens(&value_convert, &mut _s); + _s + }, + ); + _s + } + }; + let q = { + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut cfg_attrs, i) = cfg_attrs.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let cfg_attrs = match cfg_attrs.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + ::quote::ToTokens::to_tokens(&cfg_attrs, &mut _s); + } + } + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Some"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&inner, &mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + _s + }; + get_dispatch.extend(q); + let q = if is_fallible_property { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "if"); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "prop"); + _s + }, + ); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::ToTokens::to_tokens(&method_await, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "props"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "insert"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "string"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "ToString"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "to_string"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "OwnedValue"); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "TryFrom"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "try_from"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Value"); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "From"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "from"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "prop"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "map_err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_or(&mut _s); + ::quote::__private::push_ident(&mut _s, "e"); + ::quote::__private::push_or(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Error"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Failed"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "to_string"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_question(&mut _s); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + _s + }, + ); + _s + } + } else { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "props"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "insert"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "string"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "ToString"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "to_string"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "OwnedValue"); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "TryFrom"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "try_from"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Value"); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "From"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "from"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::ToTokens::to_tokens(&method_await, &mut _s); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "map_err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_or(&mut _s); + ::quote::__private::push_ident(&mut _s, "e"); + ::quote::__private::push_or(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Error"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Failed"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "to_string"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_question(&mut _s); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + _s + } + }; + get_all.extend(q); + let prop_value_handled = if is_fallible_property { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::ToTokens::to_tokens(&method_await, &mut _s); + ::quote::__private::push_question(&mut _s); + _s + } + } else { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::ToTokens::to_tokens(&method_await, &mut _s); + _s + } + }; + let prop_changed_method = { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "pub"); + ::quote::__private::push_ident(&mut _s, "async"); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::ToTokens::to_tokens( + &prop_changed_method_name, + &mut _s, + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "signal_context"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "SignalContext"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'_"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_rarrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "mut"); + ::quote::__private::push_ident(&mut _s, "changed"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "collections"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "HashMap"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "new"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "value"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Value"); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "From"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "from"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&prop_value_handled, &mut _s); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_ident(&mut _s, "changed"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "insert"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "value"); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Properties"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident( + &mut _s, + "properties_changed", + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "signal_context"); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "names"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "InterfaceName"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident( + &mut _s, + "from_static_str_unchecked", + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&iface_name, &mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "changed"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Bracket, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + _s + }, + ); + _s + }; + generated_signals.extend(prop_changed_method); + let prop_invalidate_method = { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "pub"); + ::quote::__private::push_ident(&mut _s, "async"); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::ToTokens::to_tokens( + &prop_invalidate_method_name, + &mut _s, + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "signal_context"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "SignalContext"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'_"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_rarrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Properties"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident( + &mut _s, + "properties_changed", + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "signal_context"); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "names"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "InterfaceName"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident( + &mut _s, + "from_static_str_unchecked", + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&iface_name, &mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "collections"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "HashMap"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "new"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Bracket, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + _s + }, + ); + _s + }; + generated_signals.extend(prop_invalidate_method); + } + } + MethodType::Other => { + introspect.extend(doc_comments); + introspect.extend(introspect_method(&member_name, &intro_args)); + let m = { + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut cfg_attrs, i) = cfg_attrs.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let cfg_attrs = match cfg_attrs.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + ::quote::ToTokens::to_tokens(&cfg_attrs, &mut _s); + } + } + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "future"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "async"); + ::quote::__private::push_ident(&mut _s, "move"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&args_from_msg, &mut _s); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "reply"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_dot(&mut _s); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&args_names, &mut _s); + _s + }, + ); + ::quote::ToTokens::to_tokens(&method_await, &mut _s); + ::quote::__private::push_semi(&mut _s); + ::quote::ToTokens::to_tokens(&reply, &mut _s); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Async"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "boxed"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Box"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "pin"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "async"); + ::quote::__private::push_ident(&mut _s, "move"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "future"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + _s + }, + ); + _s + }, + ); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_comma(&mut _s); + _s + }; + if is_mut { + call_dispatch + .extend({ + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut cfg_attrs, i) = cfg_attrs.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let cfg_attrs = match cfg_attrs.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + ::quote::ToTokens::to_tokens(&cfg_attrs, &mut _s); + } + } + ::quote::ToTokens::to_tokens(&member_name, &mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "RequiresMut"); + ::quote::__private::push_comma(&mut _s); + _s + }); + call_mut_dispatch.extend(m); + } else { + call_dispatch.extend(m); + } + } + } + } + introspect_properties(&mut introspect, properties)?; + let generics = &input.generics; + let where_clause = &generics.where_clause; + let generated_signals_impl = if generated_signals.is_empty() { + ::quote::__private::TokenStream::new() + } else { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "impl"); + ::quote::ToTokens::to_tokens(&generics, &mut _s); + ::quote::ToTokens::to_tokens(&self_ty, &mut _s); + ::quote::ToTokens::to_tokens(&where_clause, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&generated_signals, &mut _s); + _s + }, + ); + _s + } + }; + Ok({ + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&input, &mut _s); + ::quote::ToTokens::to_tokens(&generated_signals_impl, &mut _s); + ::quote::__private::push_pound(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Bracket, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "export"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "async_trait"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "async_trait"); + _s + }, + ); + ::quote::__private::push_ident(&mut _s, "impl"); + ::quote::ToTokens::to_tokens(&generics, &mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Interface"); + ::quote::__private::push_ident(&mut _s, "for"); + ::quote::ToTokens::to_tokens(&self_ty, &mut _s); + ::quote::ToTokens::to_tokens(&where_clause, &mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::__private::push_ident(&mut _s, "name"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_rarrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "names"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "InterfaceName"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'static"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "names"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "InterfaceName"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident( + &mut _s, + "from_static_str_unchecked", + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&iface_name, &mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_ident(&mut _s, "async"); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::__private::push_ident(&mut _s, "get"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "property_name"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "str"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_rarrow(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Option"); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "OwnedValue"); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_ident(&mut _s, "property_name"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&get_dispatch, &mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "None"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_ident(&mut _s, "async"); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::__private::push_ident(&mut _s, "get_all"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_rarrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "collections"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "HashMap"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "string"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "String"); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "OwnedValue"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "mut"); + ::quote::__private::push_ident(&mut _s, "props"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "collections"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "HashMap"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "string"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "String"); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "OwnedValue"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "collections"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "HashMap"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "new"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::ToTokens::to_tokens(&get_all, &mut _s); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "props"); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::__private::push_ident(&mut _s, "set"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "property_name"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_ident(&mut _s, "str"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "value"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Value"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'_"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "signal_context"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "SignalContext"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'_"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_rarrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_ident(&mut _s, "property_name"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&set_dispatch, &mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "NotFound"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_ident(&mut _s, "async"); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::__private::push_ident(&mut _s, "set_mut"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "mut"); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "property_name"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "str"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "value"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Value"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'_"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "signal_context"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "SignalContext"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'_"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_rarrow(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Option"); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_ident(&mut _s, "property_name"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&set_mut_dispatch, &mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "None"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::__private::push_ident(&mut _s, "call"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "s"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "ObjectServer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "c"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Connection"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "m"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "message"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Message"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "name"); + ::quote::__private::push_colon(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "names"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "MemberName"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_rarrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_ident(&mut _s, "name"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "as_str"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&call_dispatch, &mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "NotFound"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::__private::push_ident(&mut _s, "call_mut"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_ident(&mut _s, "mut"); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "s"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "ObjectServer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "c"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Connection"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "m"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "message"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Message"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "name"); + ::quote::__private::push_colon(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "names"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "MemberName"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_rarrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_lifetime(&mut _s, "\'call"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_ident(&mut _s, "name"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "as_str"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&call_mut_dispatch, &mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "DispatchResult"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "NotFound"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_ident(&mut _s, "fn"); + ::quote::__private::push_ident(&mut _s, "introspect_to_writer"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "self"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "mut"); + ::quote::__private::push_ident(&mut _s, "dyn"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fmt"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Write"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_ident(&mut _s, "usize"); + _s + }, + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "r#\"{:indent$}\"#", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_ident(&mut _s, "Self"); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Interface"); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "name"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "use"); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "zvariant"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Type"); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_add(&mut _s); + ::quote::__private::parse(&mut _s, "2"); + ::quote::__private::push_semi(&mut _s); + ::quote::ToTokens::to_tokens(&introspect, &mut _s); + _s + }, + ); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "r#\"{:indent$}\"#", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + _s + }, + ); + _s + }, + ); + _s + }) + } + fn get_args_from_inputs>( + inputs: &[PatType], + zbus: &TokenStream, + ) -> syn::Result<(TokenStream, TokenStream)> { + if inputs.is_empty() { + Ok(( + ::quote::__private::TokenStream::new(), + ::quote::__private::TokenStream::new(), + )) + } else { + let mut server_arg_decl = None; + let mut conn_arg_decl = None; + let mut header_arg_decl = None; + let mut signal_context_arg_decl = None; + let mut args_names = Vec::new(); + let mut tys = Vec::new(); + for input in inputs { + let (object_server, connection, header, signal_context) = match A::parse( + &input.attrs, + )? + .into() + { + ArgAttrs::Old(old) => { + { + ::std::io::_eprint( + format_args!("{0}\n", DEPRECATION_WARNING), + ); + }; + ( + old.object_server, + old.connection, + old.header, + old.signal_context, + ) + } + ArgAttrs::New(new) => { + ( + new.object_server, + new.connection, + new.header, + new.signal_context, + ) + } + }; + if object_server { + if server_arg_decl.is_some() { + return Err( + Error::new_spanned( + input, + "There can only be one object_server argument", + ), + ); + } + let server_arg = &input.pat; + server_arg_decl = Some({ + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::ToTokens::to_tokens(&server_arg, &mut _s); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "s"); + ::quote::__private::push_semi(&mut _s); + _s + }); + } else if connection { + if conn_arg_decl.is_some() { + return Err( + Error::new_spanned( + input, + "There can only be one connection argument", + ), + ); + } + let conn_arg = &input.pat; + conn_arg_decl = Some({ + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::ToTokens::to_tokens(&conn_arg, &mut _s); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "c"); + ::quote::__private::push_semi(&mut _s); + _s + }); + } else if header { + if header_arg_decl.is_some() { + return Err( + Error::new_spanned( + input, + "There can only be one header argument", + ), + ); + } + let header_arg = &input.pat; + header_arg_decl = Some({ + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::ToTokens::to_tokens(&header_arg, &mut _s); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "m"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "header"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + _s + }); + } else if signal_context { + if signal_context_arg_decl.is_some() { + return Err( + Error::new_spanned( + input, + "There can only be one `signal_context` argument", + ), + ); + } + let signal_context_arg = &input.pat; + signal_context_arg_decl = Some({ + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::ToTokens::to_tokens(&signal_context_arg, &mut _s); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_ident(&mut _s, "hdr"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "path"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Some"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "p"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "object_server"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "SignalContext"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "new"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "c"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "p"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "expect"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::parse( + &mut _s, + "\"Infallible conversion failed\"", + ); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Option"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "None"); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "err"); + ::quote::__private::push_eq(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Error"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "UnknownObject"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::parse(&mut _s, "\"Path Required\""); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "into"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_ident(&mut _s, "return"); + ::quote::__private::push_ident(&mut _s, "c"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "reply_dbus_error"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "hdr"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "err"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + ::quote::__private::push_semi(&mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + _s + }); + } else { + args_names.push(pat_ident(input).unwrap()); + tys.push(&input.ty); + } + } + let args_from_msg = { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "hdr"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "m"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "header"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "msg_body"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "m"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "body"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::ToTokens::to_tokens(&server_arg_decl, &mut _s); + ::quote::ToTokens::to_tokens(&conn_arg_decl, &mut _s); + ::quote::ToTokens::to_tokens(&header_arg_decl, &mut _s); + ::quote::ToTokens::to_tokens(&signal_context_arg_decl, &mut _s); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let mut _i = 0usize; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut args_names, i) = args_names.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let args_names = match args_names.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + if _i > 0 { + ::quote::__private::push_comma(&mut _s); + } + _i += 1; + ::quote::ToTokens::to_tokens(&args_names, &mut _s); + } + } + _s + }, + ); + ::quote::__private::push_colon(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let mut _i = 0usize; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut tys, i) = tys.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let tys = match tys.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + if _i > 0 { + ::quote::__private::push_comma(&mut _s); + } + _i += 1; + ::quote::ToTokens::to_tokens(&tys, &mut _s); + } + } + _s + }, + ); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "match"); + ::quote::__private::push_ident(&mut _s, "msg_body"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "deserialize"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Ok"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "r"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_ident(&mut _s, "r"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Result"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Err"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + ::quote::__private::push_fat_arrow(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "err"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&zbus, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "fdo"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "Error"); + ::quote::__private::push_ident(&mut _s, "as"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "convert"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "From"); + ::quote::__private::push_lt(&mut _s); + ::quote::__private::push_underscore(&mut _s); + ::quote::__private::push_shr(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "from"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "e"); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_ident(&mut _s, "return"); + ::quote::__private::push_ident(&mut _s, "c"); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "reply_dbus_error"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_and(&mut _s); + ::quote::__private::push_ident(&mut _s, "hdr"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "err"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "await"); + ::quote::__private::push_semi(&mut _s); + _s + }, + ); + _s + }, + ); + ::quote::__private::push_semi(&mut _s); + _s + }; + let all_args_names = inputs.iter().filter_map(pat_ident); + let all_args_names = { + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut all_args_names, i) = all_args_names.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let all_args_names = match all_args_names.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + ::quote::ToTokens::to_tokens(&all_args_names, &mut _s); + ::quote::__private::push_comma(&mut _s); + } + } + _s + }; + Ok((args_from_msg, all_args_names)) + } + } + fn clean_input_args(inputs: &mut Punctuated) { + for input in inputs { + if let FnArg::Typed(t) = input { + t.attrs.retain(|attr| !attr.path.is_ident("zbus")); + } + } + } + fn introspect_signal(name: &str, args: &TokenStream) -> TokenStream { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "\"{:indent$}\"", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&name, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_add(&mut _s); + ::quote::__private::parse(&mut _s, "2"); + ::quote::__private::push_semi(&mut _s); + ::quote::ToTokens::to_tokens(&args, &mut _s); + _s + }, + ); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"{:indent$}\""); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + _s + } + } + fn introspect_method(name: &str, args: &TokenStream) -> TokenStream { + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "\"{:indent$}\"", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&name, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Brace, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "let"); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_add(&mut _s); + ::quote::__private::parse(&mut _s, "2"); + ::quote::__private::push_semi(&mut _s); + ::quote::ToTokens::to_tokens(&args, &mut _s); + _s + }, + ); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"{:indent$}\""); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + _s + } + } + fn introspect_input_args<'i>( + inputs: &'i [PatType], + is_signal: bool, + cfg_attrs: &'i [&'i syn::Attribute], + ) -> impl Iterator + 'i { + inputs + .iter() + .filter_map(move |pat_type @ PatType { ty, attrs, .. }| { + let is_special_arg = attrs + .iter() + .any(|attr| { + if !attr.path.is_ident("zbus") { + return false; + } + let meta = match attr.parse_meta() { + ::std::result::Result::Ok(meta) => meta, + ::std::result::Result::Err(_) => return false, + }; + let nested = match meta { + Meta::List(MetaList { nested, .. }) => nested, + _ => return false, + }; + let res = nested + .iter() + .any(|nested_meta| { + match nested_meta { + NestedMeta::Meta( + Meta::Path(path), + ) if path.is_ident("object_server") + || path.is_ident("connection") || path.is_ident("header") + || path.is_ident("signal_context") => true, + _ => false, + } + }); + res + }); + if is_special_arg { + return None; + } + let ident = pat_ident(pat_type).unwrap(); + let arg_name = { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&ident, &mut _s); + _s + } + .to_string(); + let dir = if is_signal { "" } else { " direction=\"in\"" }; + Some({ + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut cfg_attrs, i) = cfg_attrs.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let cfg_attrs = match cfg_attrs.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + ::quote::ToTokens::to_tokens(&cfg_attrs, &mut _s); + } + } + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "\"{:indent$}\"", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&arg_name, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&ty, &mut _s); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "signature"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&dir, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + _s + }) + }) + } + fn introspect_output_arg( + ty: &Type, + arg_name: Option<&String>, + cfg_attrs: &[&syn::Attribute], + ) -> TokenStream { + let arg_name = match arg_name { + Some(name) => { + let res = ::alloc::fmt::format(format_args!("name=\"{0}\" ", name)); + res + } + None => String::from(""), + }; + { + let mut _s = ::quote::__private::TokenStream::new(); + { + use ::quote::__private::ext::*; + let has_iter = ::quote::__private::ThereIsNoIteratorInRepetition; + #[allow(unused_mut)] + let (mut cfg_attrs, i) = cfg_attrs.quote_into_iter(); + let has_iter = has_iter | i; + let _: ::quote::__private::HasIterator = has_iter; + while true { + let cfg_attrs = match cfg_attrs.next() { + Some(_x) => ::quote::__private::RepInterp(_x), + None => break, + }; + ::quote::ToTokens::to_tokens(&cfg_attrs, &mut _s); + } + } + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "\"{:indent$}\"", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&arg_name, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&ty, &mut _s); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "signature"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + _s + } + } + fn get_result_type(p: &TypePath) -> syn::Result<&Type> { + if let PathArguments::AngleBracketed(AngleBracketedGenericArguments { args, .. }) + = &p + .path + .segments + .last() + .ok_or_else(|| Error::new_spanned(p, "unsupported result type"))? + .arguments + { + if let Some(syn::GenericArgument::Type(ty)) = args.first() { + return Ok(ty); + } + } + Err(Error::new_spanned(p, "unhandled Result return")) + } + fn introspect_add_output_args( + args: &mut TokenStream, + output: &ReturnType, + arg_names: Option<&[String]>, + cfg_attrs: &[&syn::Attribute], + ) -> syn::Result { + let mut is_result_output = false; + if let ReturnType::Type(_, ty) = output { + let mut ty = ty.as_ref(); + if let Type::Path(p) = ty { + is_result_output = p + .path + .segments + .last() + .ok_or_else(|| Error::new_spanned(ty, "unsupported output type"))? + .ident == "Result"; + if is_result_output { + ty = get_result_type(p)?; + } + } + if let Type::Tuple(t) = ty { + if let Some(arg_names) = arg_names { + if t.elems.len() != arg_names.len() { + { + ::core::panicking::panic_fmt( + format_args!( + "Number of out arg names different from out args specified" + ), + ); + } + } + } + for i in 0..t.elems.len() { + let name = arg_names.map(|names| &names[i]); + args.extend(introspect_output_arg(&t.elems[i], name, cfg_attrs)); + } + } else { + args.extend(introspect_output_arg(ty, None, cfg_attrs)); + } + } + Ok(is_result_output) + } + fn get_property_type(output: &ReturnType) -> syn::Result<&Type> { + if let ReturnType::Type(_, ty) = output { + let ty = ty.as_ref(); + if let Type::Path(p) = ty { + let is_result_output = p + .path + .segments + .last() + .ok_or_else(|| Error::new_spanned(ty, "unsupported property type"))? + .ident == "Result"; + if is_result_output { + return get_result_type(p); + } + } + Ok(ty) + } else { + Err(Error::new_spanned(output, "Invalid property getter")) + } + } + fn introspect_properties( + introspection: &mut TokenStream, + properties: BTreeMap>, + ) -> syn::Result<()> { + for (name, prop) in properties { + let access = if prop.read && prop.write { + "readwrite" + } else if prop.read { + "read" + } else if prop.write { + "write" + } else { + return Err( + Error::new_spanned(name, "property is neither readable nor writable"), + ); + }; + let ty = prop + .ty + .ok_or_else(|| { + Error::new_spanned( + &name, + "Write-only properties aren't supported yet", + ) + })?; + let doc_comments = prop.doc_comments; + if prop.emits_changed_signal == PropertyEmitsChangedSignal::True { + introspection + .extend({ + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&doc_comments, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "\"{:indent$}\"", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&name, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&ty, &mut _s); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "signature"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&access, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + _s + }); + } else { + let emits_changed_signal = prop.emits_changed_signal.to_string(); + introspection + .extend({ + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::ToTokens::to_tokens(&doc_comments, &mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "\"{:indent$}\"", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&name, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_lt(&mut _s); + ::quote::ToTokens::to_tokens(&ty, &mut _s); + ::quote::__private::push_gt(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "signature"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens(&access, &mut _s); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "\"{:indent$}\"", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::ToTokens::to_tokens( + &emits_changed_signal, + &mut _s, + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_add(&mut _s); + ::quote::__private::parse(&mut _s, "2"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse( + &mut _s, + "\"{:indent$}\"", + ); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + ::quote::__private::push_comma(&mut _s); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + _s + }); + } + } + Ok(()) + } + pub fn to_xml_docs(lines: Vec) -> TokenStream { + let mut docs = ::quote::__private::TokenStream::new(); + let mut lines: Vec<&str> = lines + .iter() + .skip_while(|s| is_blank(s)) + .flat_map(|s| s.split('\n')) + .collect(); + while let Some(true) = lines.last().map(|s| is_blank(s)) { + lines.pop(); + } + if lines.is_empty() { + return docs; + } + docs.extend({ + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "std"); + ::quote::__private::push_colon2(&mut _s); + ::quote::__private::push_ident(&mut _s, "writeln"); + ::quote::__private::push_bang(&mut _s); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + { + let mut _s = ::quote::__private::TokenStream::new(); + ::quote::__private::push_ident(&mut _s, "writer"); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"{:indent$}\""); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::parse(&mut _s, "\"\""); + ::quote::__private::push_comma(&mut _s); + ::quote::__private::push_ident(&mut _s, "indent"); + ::quote::__private::push_eq(&mut _s); + ::quote::__private::push_ident(&mut _s, "level"); + _s + }, + ); + ::quote::__private::push_dot(&mut _s); + ::quote::__private::push_ident(&mut _s, "unwrap"); + ::quote::__private::push_group( + &mut _s, + ::quote::__private::Delimiter::Parenthesis, + ::quote::__private::TokenStream::new(), + ); + ::quote::__private::push_semi(&mut _s); + _s + }); + docs + } +} diff --git a/zbus_macros/src/error.rs b/zbus_macros/src/error.rs index 95dafd02b..1614e2417 100644 --- a/zbus_macros/src/error.rs +++ b/zbus_macros/src/error.rs @@ -3,9 +3,28 @@ use quote::{quote, ToTokens}; use syn::{spanned::Spanned, Data, DeriveInput, Error, Fields, Ident, Variant}; use zvariant_utils::def_attrs; -// FIXME: The list name should once be "zbus" instead of "dbus_error" (like in serde). +const DEPRECATION_WARNING: &str = + "The `#[dbus_error(...)]` attribute of error has been deprecated in favor of `#[zbus(...)]`."; + +mod old { + use zvariant_utils::def_attrs; + def_attrs! { + crate dbus_error; + + pub StructAttributes("struct") { + prefix str, + impl_display bool + }; + + pub VariantAttributes("enum variant") { + name str, + zbus none + }; + } +} + def_attrs! { - crate dbus_error; + crate zbus; pub StructAttributes("struct") { prefix str, @@ -14,7 +33,7 @@ def_attrs! { pub VariantAttributes("enum variant") { name str, - zbus_error none + zbus none }; } @@ -25,8 +44,28 @@ pub fn expand_derive(input: DeriveInput) -> Result { prefix, impl_display, } = StructAttributes::parse(&input.attrs)?; - let prefix = prefix.unwrap_or_else(|| "org.freedesktop.DBus".to_string()); - let generate_display = impl_display.unwrap_or(true); + let old::StructAttributes { + prefix: old_prefix, + impl_display: old_impl_display, + } = old::StructAttributes::parse(&input.attrs)?; + let prefix = prefix + .or_else(|| match old_prefix { + Some(p) => { + eprintln!("{}", DEPRECATION_WARNING); + Some(p) + } + None => None, + }) + .unwrap_or_else(|| "org.freedesktop.DBus".to_string()); + let generate_display = impl_display + .or_else(|| match old_impl_display { + Some(disp) => { + eprintln!("{}", DEPRECATION_WARNING); + Some(disp) + } + None => None, + }) + .unwrap_or(true); let (_vis, name, _generics, data) = match input.data { Data::Enum(data) => (input.vis, input.ident, input.generics, data), @@ -42,10 +81,29 @@ pub fn expand_derive(input: DeriveInput) -> Result { let mut zbus_error_variant = None; for variant in data.variants { - let VariantAttributes { name, zbus_error } = VariantAttributes::parse(&variant.attrs)?; + let VariantAttributes { + name: new_name, + zbus: new_zbus_error, + } = VariantAttributes::parse(&variant.attrs)?; + let old::VariantAttributes { + name: old_name, + zbus: old_zbus_error, + } = old::VariantAttributes::parse(&variant.attrs)?; let ident = &variant.ident; - let name = name.unwrap_or_else(|| ident.to_string()); + let name = new_name + .or_else(|| match old_name { + Some(name) => { + eprintln!("{}", DEPRECATION_WARNING); + Some(name) + } + None => None, + }) + .unwrap_or_else(|| ident.to_string()); + if old_zbus_error { + eprintln!("{}", DEPRECATION_WARNING); + } + let zbus_error = new_zbus_error || old_zbus_error; let fqn = if !zbus_error { format!("{prefix}.{name}") diff --git a/zbus_macros/src/iface.rs b/zbus_macros/src/iface.rs index cbdff493e..89681d13a 100644 --- a/zbus_macros/src/iface.rs +++ b/zbus_macros/src/iface.rs @@ -7,13 +7,52 @@ use syn::{ Lit::Str, Meta, Meta::NameValue, MetaList, MetaNameValue, NestedMeta, PatType, PathArguments, ReturnType, Signature, Token, Type, TypePath, }; -use zvariant_utils::{case, def_attrs}; +use zvariant_utils::{case, def_attrs, macros::AttrParse, old_new}; use crate::utils::*; -// FIXME: The list name should once be "zbus" instead of "dbus_interface" (like in serde). +const DEPRECATION_WARNING: &str = + "The `#[dbus_interface(...)]` attribute of interface has been deprecated in favor of `#[zbus(...)]`."; + +pub mod old { + use super::def_attrs; + def_attrs! { + crate dbus_interface; + + pub TraitAttributes("trait") { + interface str, + name str + }; + + pub MethodAttributes("method") { + name str, + signal none, + property { + pub PropertyAttributes("property") { + emits_changed_signal str + } + }, + out_args [str] + }; + } + mod arg_attrs { + use super::def_attrs; + def_attrs! { + crate dbus_interface; + + pub ArgAttributes("argument") { + object_server none, + connection none, + header none, + signal_context none + }; + } + } + pub use arg_attrs::ArgAttributes; +} + def_attrs! { - crate dbus_interface; + crate zbus; pub TraitAttributes("trait") { interface str, @@ -47,7 +86,11 @@ mod arg_attrs { } } -use arg_attrs::ArgAttributes; +pub use arg_attrs::ArgAttributes; + +old_new!(ArgAttrs, old::ArgAttributes, ArgAttributes); +old_new!(TraitAttrs, old::TraitAttributes, TraitAttributes); +old_new!(MethodAttrs, old::MethodAttributes, MethodAttributes); #[derive(Debug)] struct Property<'a> { @@ -115,10 +158,10 @@ struct MethodInfo { } impl MethodInfo { - fn new( + fn new + AttrParse>( zbus: &TokenStream, method: &ImplItemMethod, - attrs: &MethodAttributes, + attrs: &MethodAttrs, cfg_attrs: &[&Attribute], ) -> syn::Result { let is_async = method.sig.asyncness.is_some(); @@ -141,9 +184,20 @@ impl MethodInfo { }) .collect(); let doc_comments = to_xml_docs(docs); - let is_property = attrs.property.is_some(); - let is_signal = attrs.signal; - let out_args: Option<&[String]> = attrs.out_args.as_deref(); + let (is_property, is_signal, out_args, attrs_name) = match attrs { + MethodAttrs::Old(old) => ( + old.property.is_some(), + old.signal, + old.out_args.clone(), + old.name.clone(), + ), + MethodAttrs::New(new) => ( + new.property.is_some(), + new.signal, + new.out_args.clone(), + new.name.clone(), + ), + }; assert!(!is_property || !is_signal); let has_inputs = inputs.len() > 1; @@ -187,9 +241,9 @@ impl MethodInfo { let mut intro_args = quote!(); intro_args.extend(introspect_input_args(&typed_inputs, is_signal, cfg_attrs)); let is_result_output = - introspect_add_output_args(&mut intro_args, output, out_args, cfg_attrs)?; + introspect_add_output_args(&mut intro_args, output, out_args.as_deref(), cfg_attrs)?; - let (args_from_msg, args_names) = get_args_from_inputs(&typed_inputs, zbus)?; + let (args_from_msg, args_names) = get_args_from_inputs::(&typed_inputs, zbus)?; let reply = if is_result_output { let ret = quote!(r); @@ -205,7 +259,7 @@ impl MethodInfo { quote!(c.reply(m, &reply).await) }; - let member_name = attrs.name.clone().unwrap_or_else(|| { + let member_name = attrs_name.clone().unwrap_or_else(|| { let mut name = ident.to_string(); if is_property && has_inputs { assert!(name.starts_with("set_")); @@ -245,7 +299,14 @@ impl MethodInfo { } } -pub fn expand(args: AttributeArgs, mut input: ItemImpl) -> syn::Result { +pub fn expand< + T: AttrParse + Into, + M: AttrParse + Into, + A: AttrParse + Into, +>( + args: AttributeArgs, + mut input: ItemImpl, +) -> syn::Result { let zbus = zbus_path(); let self_ty = &input.self_ty; @@ -254,6 +315,8 @@ pub fn expand(args: AttributeArgs, mut input: ItemImpl) -> syn::Result syn::Result (new.name, new.interface), + TraitAttrs::Old(old) => { + eprintln!("{}", DEPRECATION_WARNING); + (old.name, old.interface) + } + }; match (name, interface) { (Some(name), None) | (None, Some(name)) => name, @@ -292,19 +361,40 @@ pub fn expand(args: AttributeArgs, mut input: ItemImpl) -> syn::Result m, _ => continue, }; - let attrs = MethodAttributes::parse(&method.attrs)?; - method - .attrs - .retain(|attr| !attr.path.is_ident("dbus_interface")); + let attrs = M::parse(&method.attrs)?.into(); + if let MethodAttrs::Old(_) = attrs { + eprintln!("{}", DEPRECATION_WARNING); + } + + method.attrs.retain(|attr| { + match ( + attr.path.is_ident("zbus"), + attr.path.is_ident("dbus_interface"), + ) { + (true, _) => false, + (_, true) => { + eprintln!("{}", DEPRECATION_WARNING); + false + } + _ => true, + } + }); + let cfg_attrs: Vec<_> = method .attrs .iter() .filter(|a| a.path.is_ident("cfg")) .collect(); - let method_info = MethodInfo::new(&zbus, method, &attrs, &cfg_attrs)?; - if let Some(prop_attrs) = &attrs.property { + let method_info = MethodInfo::new::(&zbus, method, &attrs, &cfg_attrs)?; + let attr_property = match attrs { + MethodAttrs::Old(o) => o.property.map(|op| PropertyAttributes { + emits_changed_signal: op.emits_changed_signal, + }), + MethodAttrs::New(n) => n.property, + }; + if let Some(prop_attrs) = &attr_property { if method_info.method_type == MethodType::Property(PropertyType::NoInputs) { let emits_changed_signal = if let Some(s) = &prop_attrs.emits_changed_signal { PropertyEmitsChangedSignal::parse(s, method.span())? @@ -767,7 +857,7 @@ pub fn expand(args: AttributeArgs, mut input: ItemImpl) -> syn::Result>( inputs: &[PatType], zbus: &TokenStream, ) -> syn::Result<(TokenStream, TokenStream)> { @@ -782,9 +872,26 @@ fn get_args_from_inputs( let mut tys = Vec::new(); for input in inputs { - let attrs = ArgAttributes::parse(&input.attrs)?; + let (object_server, connection, header, signal_context) = + match A::parse(&input.attrs)?.into() { + ArgAttrs::Old(old) => { + eprintln!("{}", DEPRECATION_WARNING); + ( + old.object_server, + old.connection, + old.header, + old.signal_context, + ) + } + ArgAttrs::New(new) => ( + new.object_server, + new.connection, + new.header, + new.signal_context, + ), + }; - if attrs.object_server { + if object_server { if server_arg_decl.is_some() { return Err(Error::new_spanned( input, @@ -794,7 +901,7 @@ fn get_args_from_inputs( let server_arg = &input.pat; server_arg_decl = Some(quote! { let #server_arg = &s; }); - } else if attrs.connection { + } else if connection { if conn_arg_decl.is_some() { return Err(Error::new_spanned( input, @@ -804,7 +911,7 @@ fn get_args_from_inputs( let conn_arg = &input.pat; conn_arg_decl = Some(quote! { let #conn_arg = &c; }); - } else if attrs.header { + } else if header { if header_arg_decl.is_some() { return Err(Error::new_spanned( input, @@ -817,7 +924,7 @@ fn get_args_from_inputs( header_arg_decl = Some(quote! { let #header_arg = m.header(); }); - } else if attrs.signal_context { + } else if signal_context { if signal_context_arg_decl.is_some() { return Err(Error::new_spanned( input, diff --git a/zbus_macros/src/lib.rs b/zbus_macros/src/lib.rs index 793210303..801e710e2 100644 --- a/zbus_macros/src/lib.rs +++ b/zbus_macros/src/lib.rs @@ -46,13 +46,13 @@ mod utils; /// * `blocking_name` - Specify the exact name of the blocking proxy type. /// /// * `assume_defaults` - whether to auto-generate values for `default_path` and `default_service` -/// if none are specified (default: `false`). `dbus_proxy` generates a warning if neither this +/// if none are specified (default: `false`). `proxy` generates a warning if neither this /// attribute nor one of the default values are specified. Please make sure to explicitly set /// either this attribute or the default values, according to your needs. /// /// Each trait method will be expanded to call to the associated D-Bus remote interface. /// -/// Trait methods accept `dbus_proxy` attributes: +/// Trait methods accept `proxy` attributes: /// /// * `name` - override the D-Bus name (pascal case form by default) /// @@ -108,12 +108,12 @@ mod utils; /// /// ```no_run /// # use std::error::Error; -/// use zbus_macros::dbus_proxy; +/// use zbus_macros::proxy; /// use zbus::{blocking::Connection, Result, fdo, zvariant::Value}; /// use futures_util::stream::StreamExt; /// use async_io::block_on; /// -/// #[dbus_proxy( +/// #[proxy( /// interface = "org.test.SomeIface", /// default_service = "org.test.SomeService", /// default_path = "/org/test/SomeObject" @@ -121,16 +121,16 @@ mod utils; /// trait SomeIface { /// fn do_this(&self, with: &str, some: u32, arg: &Value<'_>) -> Result; /// -/// #[dbus_proxy(property)] +/// #[zbus(property)] /// fn a_property(&self) -> fdo::Result; /// -/// #[dbus_proxy(property)] +/// #[zbus(property)] /// fn set_a_property(&self, a_property: &str) -> fdo::Result<()>; /// -/// #[dbus_proxy(signal)] +/// #[zbus(signal)] /// fn some_signal(&self, arg1: &str, arg2: u32) -> fdo::Result<()>; /// -/// #[dbus_proxy(object = "SomeOtherIface", blocking_object = "SomeOtherInterfaceBlock")] +/// #[zbus(object = "SomeOtherIface", blocking_object = "SomeOtherInterfaceBlock")] /// // The method will return a `SomeOtherIfaceProxy` or `SomeOtherIfaceProxyBlock`, depending /// // on whether it is called on `SomeIfaceProxy` or `SomeIfaceProxyBlocking`, respectively. /// // @@ -140,7 +140,7 @@ mod utils; /// fn some_method(&self, arg1: &str); /// } /// -/// #[dbus_proxy( +/// #[proxy( /// interface = "org.test.SomeOtherIface", /// default_service = "org.test.SomeOtherService", /// blocking_name = "SomeOtherInterfaceBlock", @@ -191,10 +191,20 @@ mod utils; /// [`ObjectPath`]: https://docs.rs/zvariant/latest/zvariant/struct.ObjectPath.html /// [dbus_emits_changed_signal]: https://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format #[proc_macro_attribute] +pub fn proxy(attr: TokenStream, item: TokenStream) -> TokenStream { + let args = parse_macro_input!(attr as AttributeArgs); + let input = parse_macro_input!(item as ItemTrait); + proxy::expand::(args, input) + .unwrap_or_else(|err| err.to_compile_error()) + .into() +} + +#[deprecated = "Use #[proxy(...)] instead."] +#[proc_macro_attribute] pub fn dbus_proxy(attr: TokenStream, item: TokenStream) -> TokenStream { let args = parse_macro_input!(attr as AttributeArgs); let input = parse_macro_input!(item as ItemTrait); - proxy::expand(args, input) + proxy::expand::(args, input) .unwrap_or_else(|err| err.to_compile_error()) .into() } @@ -205,7 +215,7 @@ pub fn dbus_proxy(attr: TokenStream, item: TokenStream) -> TokenStream { /// properties or signal depending on the item attributes. It will implement the [`Interface`] trait /// `for T` on your behalf, to handle the message dispatching and introspection support. /// -/// The methods accepts the `dbus_interface` attributes: +/// The methods accepts the `interface` attributes: /// /// * `name` - override the D-Bus name (pascal case form of the method by default) /// @@ -265,14 +275,14 @@ pub fn dbus_proxy(attr: TokenStream, item: TokenStream) -> TokenStream { /// /// ``` /// # use std::error::Error; -/// use zbus_macros::dbus_interface; +/// use zbus_macros::interface; /// use zbus::{ObjectServer, object_server::SignalContext, message::Header}; /// /// struct Example { /// _some_data: String, /// } /// -/// #[dbus_interface(name = "org.myservice.Example")] +/// #[interface(name = "org.myservice.Example")] /// impl Example { /// // "Quit" method. A method may throw errors. /// async fn quit( @@ -296,7 +306,7 @@ pub fn dbus_proxy(attr: TokenStream, item: TokenStream) -> TokenStream { /// // "TheAnswer" property (note: the "name" attribute), with its associated getter. /// // A `the_answer_changed` method has also been generated to emit the /// // "PropertiesChanged" signal for this property. -/// #[dbus_interface(property, name = "TheAnswer")] +/// #[zbus(property, name = "TheAnswer")] /// fn answer(&self) -> u32 { /// 2 * 3 * 7 /// } @@ -304,16 +314,16 @@ pub fn dbus_proxy(attr: TokenStream, item: TokenStream) -> TokenStream { /// // "IFail" property with its associated getter. /// // An `i_fail_changed` method has also been generated to emit the /// // "PropertiesChanged" signal for this property. -/// #[dbus_interface(property)] +/// #[zbus(property)] /// fn i_fail(&self) -> zbus::fdo::Result { /// Err(zbus::fdo::Error::UnknownProperty("IFail".into())) /// } /// /// // "Bye" signal (note: no implementation body). -/// #[dbus_interface(signal)] +/// #[zbus(signal)] /// async fn bye(signal_ctxt: &SignalContext<'_>, message: &str) -> zbus::Result<()>; /// -/// #[dbus_interface(out_args("answer", "question"))] +/// #[zbus(out_args("answer", "question"))] /// fn meaning_of_life(&self) -> zbus::fdo::Result<(i32, String)> { /// Ok((42, String::from("Meaning of life"))) /// } @@ -332,12 +342,28 @@ pub fn dbus_proxy(attr: TokenStream, item: TokenStream) -> TokenStream { /// [`Interface`]: https://docs.rs/zbus/latest/zbus/object_server/trait.Interface.html /// [dbus_emits_changed_signal]: https://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format #[proc_macro_attribute] +pub fn interface(attr: TokenStream, item: TokenStream) -> TokenStream { + let args = parse_macro_input!(attr); + let input = syn::parse_macro_input!(item as ItemImpl); + iface::expand::( + args, input, + ) + .unwrap_or_else(|err| err.to_compile_error()) + .into() +} + +#[deprecated = "Use #[interface(...)] instead."] +#[proc_macro_attribute] pub fn dbus_interface(attr: TokenStream, item: TokenStream) -> TokenStream { - let args = parse_macro_input!(attr as AttributeArgs); + let args = parse_macro_input!(attr); let input = syn::parse_macro_input!(item as ItemImpl); - iface::expand(args, input) - .unwrap_or_else(|err| err.to_compile_error()) - .into() + iface::expand::< + iface::old::TraitAttributes, + iface::old::MethodAttributes, + iface::old::ArgAttributes, + >(args, input) + .unwrap_or_else(|err| err.to_compile_error()) + .into() } /// Derive macro for implementing [`zbus::DBusError`] trait. @@ -345,12 +371,12 @@ pub fn dbus_interface(attr: TokenStream, item: TokenStream) -> TokenStream { /// This macro makes it easy to implement the [`zbus::DBusError`] trait for your custom error type /// (currently only enums are supported). /// -/// If a special variant marked with the `dbus_error` attribute is present, `From` is +/// If a special variant marked with the `zbus` attribute is present, `From` is /// also implemented for your type. This variant can only have a single unnamed field of type /// [`zbus::Error`]. This implementation makes it possible for you to declare proxy methods to /// directly return this type, rather than [`zbus::Error`]. /// -/// Each variant (except for the special `dbus_error` one) can optionally have a (named or unnamed) +/// Each variant (except for the special `zbus` one) can optionally have a (named or unnamed) /// `String` field (which is used as the human-readable error description). /// /// # Example @@ -359,9 +385,9 @@ pub fn dbus_interface(attr: TokenStream, item: TokenStream) -> TokenStream { /// use zbus_macros::DBusError; /// /// #[derive(DBusError, Debug)] -/// #[dbus_error(prefix = "org.myservice.App")] +/// #[zbus(prefix = "org.myservice.App")] /// enum Error { -/// #[dbus_error(zbus_error)] +/// #[zbus(zbus)] /// ZBus(zbus::Error), /// FileNotFound(String), /// OutOfMemory, @@ -372,7 +398,7 @@ pub fn dbus_interface(attr: TokenStream, item: TokenStream) -> TokenStream { /// [`zbus::Error`]: https://docs.rs/zbus/latest/zbus/enum.Error.html /// [`zvariant::Type`]: https://docs.rs/zvariant/latest/zvariant/trait.Type.html /// [`serde::Serialize`]: https://docs.rs/serde/1.0.132/serde/trait.Serialize.html -#[proc_macro_derive(DBusError, attributes(dbus_error))] +#[proc_macro_derive(DBusError, attributes(zbus, dbus_error))] pub fn derive_dbus_error(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); error::expand_derive(input) diff --git a/zbus_macros/src/proxy.rs b/zbus_macros/src/proxy.rs index e832039cf..d913ac075 100644 --- a/zbus_macros/src/proxy.rs +++ b/zbus_macros/src/proxy.rs @@ -6,11 +6,48 @@ use syn::{ self, fold::Fold, parse_quote, parse_str, spanned::Spanned, AttributeArgs, Error, FnArg, Ident, ItemTrait, Path, ReturnType, TraitItemMethod, }; -use zvariant_utils::{case, def_attrs}; +use zvariant_utils::{case, def_attrs, macros::AttrParse, old_new}; + +const DEPRECATION_WARNING: &str = + "The `#[dbus_proxy(...)]` attribute of proxy has been deprecated in favor of `#[zbus(...)]`."; + +pub mod old { + use super::def_attrs; + def_attrs! { + crate dbus_proxy; + + pub ImplAttributes("impl block") { + interface str, + name str, + assume_defaults bool, + default_path str, + default_service str, + async_name str, + blocking_name str, + gen_async bool, + gen_blocking bool + }; + + pub MethodAttributes("method") { + name str, + property { + pub PropertyAttributes("property") { + emits_changed_signal str + } + }, + signal none, + object str, + async_object str, + blocking_object str, + no_reply none, + no_autostart none, + allow_interactive_auth none + }; + } +} -// FIXME: The list name should once be "zbus" instead of "dbus_proxy" (like in serde). def_attrs! { - crate dbus_proxy; + crate zbus; pub ImplAttributes("impl block") { interface str, @@ -41,6 +78,9 @@ def_attrs! { }; } +old_new!(ImplAttrs, old::ImplAttributes, ImplAttributes); +old_new!(MethodAttrs, old::MethodAttributes, MethodAttributes); + struct AsyncOpts { blocking: bool, usage: TokenStream, @@ -62,8 +102,11 @@ impl AsyncOpts { } } -pub fn expand(args: AttributeArgs, input: ItemTrait) -> Result { - let ImplAttributes { +pub fn expand, M: AttrParse + Into>( + args: AttributeArgs, + input: ItemTrait, +) -> Result { + let ( interface, name, assume_defaults, @@ -73,7 +116,33 @@ pub fn expand(args: AttributeArgs, input: ItemTrait) -> Result { + eprintln!("{}", DEPRECATION_WARNING); + ( + old.interface, + old.name, + old.assume_defaults, + old.default_path, + old.default_service, + old.async_name, + old.blocking_name, + old.gen_async, + old.gen_blocking, + ) + } + ImplAttrs::New(new) => ( + new.interface, + new.name, + new.assume_defaults, + new.default_path, + new.default_service, + new.async_name, + new.blocking_name, + new.gen_async, + new.gen_blocking, + ), + }; let iface_name = match (interface, name) { (Some(name), None) | (None, Some(name)) => Ok(Some(name)), @@ -109,7 +178,7 @@ pub fn expand(args: AttributeArgs, input: ItemTrait) -> Result( &input, iface_name.as_deref(), assume_defaults, @@ -126,7 +195,7 @@ pub fn expand(args: AttributeArgs, input: ItemTrait) -> Result( &input, iface_name.as_deref(), assume_defaults, @@ -148,7 +217,7 @@ pub fn expand(args: AttributeArgs, input: ItemTrait) -> Result>( input: &ItemTrait, iface_name: Option<&str>, assume_defaults: Option, @@ -163,7 +232,7 @@ pub fn create_proxy( let other_attrs: Vec<_> = input .attrs .iter() - .filter(|a| !a.path.is_ident("dbus_proxy")) + .filter(|a| !a.path.is_ident("zbus")) .collect(); let proxy_name = Ident::new(proxy_name, Span::call_site()); let ident = input.ident.to_string(); @@ -193,15 +262,51 @@ pub fn create_proxy( for i in input.items.iter() { if let syn::TraitItem::Method(m) = i { - let mut attrs = MethodAttributes::parse(&m.attrs)?; + let ( + mut name, + signal, + _object, + _async_object, + _blocking_object, + _no_reply, + _no_autostart, + _allow_interactive_auth, + property, + ) = match ::parse(&m.attrs)?.into() { + MethodAttrs::Old(old) => { + eprintln!("{}", DEPRECATION_WARNING); + ( + old.name, + old.signal, + old.object, + old.async_object, + old.blocking_object, + old.no_reply, + old.no_autostart, + old.allow_interactive_auth, + old.property.map(|property| property.emits_changed_signal), + ) + } + MethodAttrs::New(new) => ( + new.name, + new.signal, + new.object, + new.async_object, + new.blocking_object, + new.no_reply, + new.no_autostart, + new.allow_interactive_auth, + new.property.map(|property| property.emits_changed_signal), + ), + }; let method_name = m.sig.ident.to_string(); - let is_property = attrs.property.is_some(); - let is_signal = attrs.signal; + let is_signal = signal; + let is_property = property.is_some(); let has_inputs = m.sig.inputs.len() > 1; - let member_name = attrs.name.take().unwrap_or_else(|| { + let member_name = name.take().unwrap_or_else(|| { case::pascal_or_camel_case( if is_property && has_inputs { assert!(method_name.starts_with("set_")); @@ -213,10 +318,10 @@ pub fn create_proxy( ) }); - let m = if let Some(prop_attrs) = &attrs.property { + let m = if let Some(prop_attrs) = &property { has_properties = true; - let emits_changed_signal = if let Some(s) = &prop_attrs.emits_changed_signal { + let emits_changed_signal = if let Some(s) = &prop_attrs { PropertyEmitsChangedSignal::parse(s, m.span())? } else { PropertyEmitsChangedSignal::True @@ -247,7 +352,13 @@ pub fn create_proxy( method } else { - gen_proxy_method_call(&member_name, &method_name, m, &attrs, &async_opts)? + gen_proxy_method_call::( + &member_name, + &method_name, + m, + ::parse(&m.attrs)?, + &async_opts, + )? }; methods.extend(m); } @@ -436,13 +547,35 @@ pub fn create_proxy( }) } -fn gen_proxy_method_call( +fn gen_proxy_method_call>( method_name: &str, snake_case_name: &str, m: &TraitItemMethod, - attrs: &MethodAttributes, + method_attrs: M, async_opts: &AsyncOpts, ) -> Result { + let (object, blocking_object, async_object, no_reply, no_autostart, allow_interactive_auth) = + match method_attrs.into() { + MethodAttrs::Old(old) => { + eprintln!("{}", DEPRECATION_WARNING); + ( + old.object, + old.blocking_object, + old.async_object, + old.no_reply, + old.no_autostart, + old.allow_interactive_auth, + ) + } + MethodAttrs::New(new) => ( + new.object, + new.blocking_object, + new.async_object, + new.no_reply, + new.no_autostart, + new.allow_interactive_auth, + ), + }; let AsyncOpts { usage, wait, @@ -452,7 +585,7 @@ fn gen_proxy_method_call( let other_attrs: Vec<_> = m .attrs .iter() - .filter(|a| !a.path.is_ident("dbus_proxy")) + .filter(|a| !a.path.is_ident("zbus")) .collect(); let args: Vec<_> = m .sig @@ -462,26 +595,21 @@ fn gen_proxy_method_call( .filter_map(pat_ident) .collect(); - let proxy_object = attrs.object.as_ref().map(|o| { + let proxy_object = object.as_ref().map(|o| { if *blocking { // FIXME: for some reason Rust doesn't let us move `blocking_proxy_object` so we've to // clone. - attrs - .blocking_object + blocking_object .as_ref() .cloned() .unwrap_or_else(|| format!("{o}ProxyBlocking")) } else { - attrs - .async_object + async_object .as_ref() .cloned() .unwrap_or_else(|| format!("{o}Proxy")) } }); - let no_reply = attrs.no_reply; - let no_autostart = attrs.no_autostart; - let allow_interactive_auth = attrs.allow_interactive_auth; let method_flags = match (no_reply, no_autostart, allow_interactive_auth) { (true, false, false) => Some(quote!(::std::convert::Into::into( @@ -641,7 +769,7 @@ fn gen_proxy_property( let other_attrs: Vec<_> = m .attrs .iter() - .filter(|a| !a.path.is_ident("dbus_proxy")) + .filter(|a| !a.path.is_ident("zbus")) .collect(); let signature = &m.sig; if signature.inputs.len() > 1 { @@ -770,7 +898,7 @@ fn gen_proxy_signal( let other_attrs: Vec<_> = method .attrs .iter() - .filter(|a| !a.path.is_ident("dbus_proxy")) + .filter(|a| !a.path.is_ident("zbus")) .collect(); let input_types: Vec<_> = method .sig diff --git a/zbus_macros/tests/tests.rs b/zbus_macros/tests/tests.rs index 7032c70b3..8ae64f1f9 100644 --- a/zbus_macros/tests/tests.rs +++ b/zbus_macros/tests/tests.rs @@ -4,16 +4,16 @@ use futures_util::{ }; use std::future::ready; use zbus::{block_on, fdo, object_server::SignalContext, proxy::CacheProperties}; -use zbus_macros::{dbus_interface, dbus_proxy, DBusError}; +use zbus_macros::{interface, proxy, DBusError}; mod param { - #[zbus_macros::dbus_proxy( + #[zbus_macros::proxy( interface = "org.freedesktop.zbus_macros.ProxyParam", default_service = "org.freedesktop.zbus_macros", default_path = "/org/freedesktop/zbus_macros/test" )] trait ProxyParam { - #[dbus_proxy(object = "super::test::Test")] + #[zbus(object = "super::test::Test")] fn some_method(&self, test: &T); } } @@ -21,7 +21,7 @@ mod param { mod test { use zbus::fdo; - #[zbus_macros::dbus_proxy( + #[zbus_macros::proxy( assume_defaults = false, interface = "org.freedesktop.zbus_macros.Test", default_service = "org.freedesktop.zbus_macros" @@ -34,22 +34,22 @@ mod test { /// which is useful to pass in a proxy as a param. It serializes it as an `ObjectPath`. fn some_method(&self, object_path: &T) -> zbus::Result<()>; - #[dbus_proxy(name = "CheckRENAMING")] + #[zbus(name = "CheckRENAMING")] fn check_renaming(&self) -> zbus::Result>; - #[dbus_proxy(property)] + #[zbus(property)] fn property(&self) -> fdo::Result>; - #[dbus_proxy(property(emits_changed_signal = "const"))] + #[zbus(property(emits_changed_signal = "const"))] fn a_const_property(&self) -> fdo::Result>; - #[dbus_proxy(property(emits_changed_signal = "false"))] + #[zbus(property(emits_changed_signal = "false"))] fn a_live_property(&self) -> fdo::Result>; - #[dbus_proxy(property)] + #[zbus(property)] fn set_property(&self, val: u16) -> fdo::Result<()>; - #[dbus_proxy(signal)] + #[zbus(signal)] fn a_signal(&self, arg: u8, other: T) -> fdo::Result<()> where T: AsRef; @@ -101,12 +101,12 @@ fn test_proxy() { #[test] fn test_derive_error() { #[derive(Debug, DBusError)] - #[dbus_error(prefix = "org.freedesktop.zbus")] + #[zbus(prefix = "org.freedesktop.zbus")] enum Test { - #[dbus_error(zbus_error)] + #[zbus(zbus)] ZBus(zbus::Error), SomeExcuse, - #[dbus_error(name = "I.Am.Sorry.Dave")] + #[zbus(name = "I.Am.Sorry.Dave")] IAmSorryDave(String), LetItBe { desc: String, @@ -130,7 +130,7 @@ fn test_interface() { #[derive(Serialize, Deserialize, Type, Value)] struct MyCustomPropertyType(u32); - #[dbus_interface(name = "org.freedesktop.zbus.Test")] + #[interface(name = "org.freedesktop.zbus.Test")] impl Test where T: serde::ser::Serialize + zbus::zvariant::Type + Send + Sync, @@ -159,34 +159,34 @@ fn test_interface() { unimplemented!() } - #[dbus_interface(property)] + #[zbus(property)] fn my_custom_property(&self) -> MyCustomPropertyType { unimplemented!() } // Also tests that mut argument bindings work for properties - #[dbus_interface(property)] + #[zbus(property)] fn set_my_custom_property(&self, mut _value: MyCustomPropertyType) { _value = MyCustomPropertyType(42); } // Test that the emits_changed_signal property results in the correct annotation - #[dbus_interface(property(emits_changed_signal = "false"))] + #[zbus(property(emits_changed_signal = "false"))] fn my_custom_property_emits_false(&self) -> MyCustomPropertyType { unimplemented!() } - #[dbus_interface(property(emits_changed_signal = "invalidates"))] + #[zbus(property(emits_changed_signal = "invalidates"))] fn my_custom_property_emits_invalidates(&self) -> MyCustomPropertyType { unimplemented!() } - #[dbus_interface(property(emits_changed_signal = "const"))] + #[zbus(property(emits_changed_signal = "const"))] fn my_custom_property_emits_const(&self) -> MyCustomPropertyType { unimplemented!() } - #[dbus_interface(name = "CheckVEC")] + #[zbus(name = "CheckVEC")] fn check_vec(&self) -> Vec { unimplemented!() } @@ -194,18 +194,18 @@ fn test_interface() { /// Testing my_prop documentation is reflected in XML. /// /// And that too. - #[dbus_interface(property)] + #[zbus(property)] fn my_prop(&self) -> u16 { unimplemented!() } - #[dbus_interface(property)] + #[zbus(property)] fn set_my_prop(&mut self, _val: u16) { unimplemented!() } /// Emit a signal. - #[dbus_interface(signal)] + #[zbus(signal)] async fn signal(ctxt: &SignalContext<'_>, arg: u8, other: &str) -> zbus::Result<()>; } @@ -284,16 +284,16 @@ mod signal_from_message { use super::*; use zbus::message::Message; - #[dbus_proxy( + #[proxy( interface = "org.freedesktop.zbus_macros.Test", default_service = "org.freedesktop.zbus_macros", default_path = "/org/freedesktop/zbus_macros/test" )] trait Test { - #[dbus_proxy(signal)] + #[zbus(signal)] fn signal_u8(&self, arg: u8) -> fdo::Result<()>; - #[dbus_proxy(signal)] + #[zbus(signal)] fn signal_string(&self, arg: String) -> fdo::Result<()>; } diff --git a/zvariant_utils/src/macros.rs b/zvariant_utils/src/macros.rs index fd3f393e8..047412158 100644 --- a/zvariant_utils/src/macros.rs +++ b/zvariant_utils/src/macros.rs @@ -136,6 +136,23 @@ pub fn match_attribute_without_value(meta: &Meta, attr: &str) -> Result { } } +/// The `AttrParse` trait is a generic interface for attribute structures. +/// This is only implemented directly by the [`crate::def_attrs`] macro, within the `zbus_macros` +/// crate. This macro allows the parsing of multiple variants when using the [`crate::old_new`] +/// macro pattern, using `` as a bounds check at compile time. +pub trait AttrParse { + fn parse_meta(&mut self, meta: &::syn::Meta) -> ::syn::Result<()>; + + fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + Self: Sized; + + fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result + where + Self: Sized; +} + /// Returns an iterator over the contents of all [`MetaList`]s with the specified identifier in an /// array of [`Attribute`]s. pub fn iter_meta_lists( @@ -395,6 +412,22 @@ macro_rules! def_attrs { $(pub $attr_name: $crate::def_attrs!(@attr_ty $kind)),+ } + impl ::zvariant_utils::macros::AttrParse for $name { + fn parse_meta( + &mut self, + meta: &::syn::Meta + ) -> ::syn::Result<()> { self.parse_meta(meta) } + + fn parse_nested_metas<'a, I>(iter: I) -> syn::Result + where + I: ::std::iter::IntoIterator, + Self: Sized { Self::parse_nested_metas(iter) } + + fn parse(attrs: &[::syn::Attribute]) -> ::syn::Result + where + Self: Sized { Self::parse(attrs) } + } + impl $name { pub fn parse_meta( &mut self, @@ -501,3 +534,35 @@ pub fn ty_is_option(ty: &Type) -> bool { _ => false, } } + +#[macro_export] +/// The `old_new` macro desognates three structures: +/// +/// 1. The enum wrapper name. +/// 2. The old type name. +/// 3. The new type name. +/// +/// The macro creates a new enumeration with two variants: `::Old(...)` and `::New(...)` +/// The old and new variants contain the old and new type, respectively. +/// It also implements `From<$old>` and `From<$new>` for the new wrapper type. +/// This is to facilitate the deprecation of extremely similar structures that have only a few +/// differences, and to be able to warn the user of the library when the `::Old(...)` variant has +/// been used. +macro_rules! old_new { + ($attr_wrapper:ident, $old:ty, $new:ty) => { + pub enum $attr_wrapper { + Old($old), + New($new), + } + impl From<$old> for $attr_wrapper { + fn from(old: $old) -> Self { + Self::Old(old) + } + } + impl From<$new> for $attr_wrapper { + fn from(new: $new) -> Self { + Self::New(new) + } + } + }; +}