diff --git a/zbus/src/fdo/object_manager.rs b/zbus/src/fdo/object_manager.rs index fa473a4ab..88b9791fa 100644 --- a/zbus/src/fdo/object_manager.rs +++ b/zbus/src/fdo/object_manager.rs @@ -4,7 +4,7 @@ //! be useful across various D-Bus applications. This module provides their proxy. use static_assertions::assert_impl_all; -use std::collections::HashMap; +use std::{borrow::Cow, collections::HashMap}; use zbus_names::{InterfaceName, OwnedInterfaceName}; use zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Value}; @@ -72,7 +72,7 @@ impl ObjectManager { pub async fn interfaces_removed( emitter: &SignalEmitter<'_>, object_path: ObjectPath<'_>, - interfaces: Vec>, + interfaces: Cow<'_, [InterfaceName<'_>]>, ) -> zbus::Result<()>; } diff --git a/zbus/src/fdo/properties.rs b/zbus/src/fdo/properties.rs index 1cafdde90..eca754e0b 100644 --- a/zbus/src/fdo/properties.rs +++ b/zbus/src/fdo/properties.rs @@ -4,7 +4,7 @@ //! be useful across various D-Bus applications. This module provides their proxy. use static_assertions::assert_impl_all; -use std::collections::HashMap; +use std::{borrow::Cow, collections::HashMap}; use zbus_names::InterfaceName; use zvariant::{OwnedValue, Value}; @@ -120,7 +120,7 @@ impl Properties { emitter: &SignalEmitter<'_>, interface_name: InterfaceName<'_>, changed_properties: HashMap<&str, Value<'_>>, - invalidated_properties: Vec<&str>, + invalidated_properties: Cow<'_, [&str]>, ) -> zbus::Result<()>; } diff --git a/zbus/src/object_server/mod.rs b/zbus/src/object_server/mod.rs index 4e485718d..7692419bd 100644 --- a/zbus/src/object_server/mod.rs +++ b/zbus/src/object_server/mod.rs @@ -196,7 +196,7 @@ impl ObjectServer { } if let Some(manager_path) = manager_path { let ctxt = SignalEmitter::new(&self.connection(), manager_path.clone())?; - ObjectManager::interfaces_removed(&ctxt, path.clone(), vec![I::name()]).await?; + ObjectManager::interfaces_removed(&ctxt, path.clone(), (&[I::name()]).into()).await?; } if node.is_empty() { let mut path_parts = path.rsplit('/').filter(|i| !i.is_empty()); diff --git a/zbus/src/proxy/mod.rs b/zbus/src/proxy/mod.rs index 175722432..ec2639c70 100644 --- a/zbus/src/proxy/mod.rs +++ b/zbus/src/proxy/mod.rs @@ -364,7 +364,7 @@ impl PropertiesCache { } Some(Either::Right(populate)) => { populate?.body().deserialize().map(|values| { - self.update_cache(&uncached_properties, &values, Vec::new(), &interface); + self.update_cache(&uncached_properties, &values, &[], &interface); })?; break; } @@ -379,7 +379,7 @@ impl PropertiesCache { self.update_cache( &uncached_properties, &args.changed_properties, - args.invalidated_properties, + &args.invalidated_properties, &interface, ); } @@ -410,7 +410,7 @@ impl PropertiesCache { self.update_cache( &uncached_properties, &args.changed_properties, - args.invalidated_properties, + &args.invalidated_properties, &interface, ); } @@ -424,13 +424,13 @@ impl PropertiesCache { &self, uncached_properties: &HashSet>, changed: &HashMap<&str, Value<'_>>, - invalidated: Vec<&str>, + invalidated: &[&str], interface: &InterfaceName<'_>, ) { let mut values = self.values.write().expect("lock poisoned"); for inval in invalidated { - if uncached_properties.contains(&Str::from(inval)) { + if uncached_properties.contains(&Str::from(*inval)) { debug!( "Ignoring invalidation of uncached property `{}.{}`", interface, inval @@ -439,7 +439,7 @@ impl PropertiesCache { } trace!("Property `{interface}.{inval}` invalidated"); - if let Some(entry) = values.get_mut(inval) { + if let Some(entry) = values.get_mut(*inval) { entry.value = None; entry.event.notify(usize::MAX); } diff --git a/zbus/tests/e2e.rs b/zbus/tests/e2e.rs index 29e187250..70a2fc261 100644 --- a/zbus/tests/e2e.rs +++ b/zbus/tests/e2e.rs @@ -727,7 +727,7 @@ async fn my_iface_test(conn: Connection, event: Event) -> zbus::Result { let args = ifaces_removed.args()?; assert_eq!(args.object_path(), "/zbus/test/MyObj"); - assert_eq!(args.interfaces(), &["org.freedesktop.MyIface"]); + assert_eq!(args.interfaces().as_ref(), &["org.freedesktop.MyIface"]); assert!(my_obj_proxy.inner().introspect().await.is_err()); assert!(my_obj_proxy.ping().await.is_err()); diff --git a/zbus_macros/src/iface.rs b/zbus_macros/src/iface.rs index 817faab97..a0ce67085 100644 --- a/zbus_macros/src/iface.rs +++ b/zbus_macros/src/iface.rs @@ -701,7 +701,7 @@ pub fn expand(args: Punctuated, mut input: ItemImpl) -> syn::Re signal_emitter, #zbus::names::InterfaceName::from_static_str_unchecked(#iface_name), changed, - vec![], + ::std::borrow::Cow::Borrowed(&[]), ).await } ); @@ -717,7 +717,7 @@ pub fn expand(args: Punctuated, mut input: ItemImpl) -> syn::Re signal_emitter, #zbus::names::InterfaceName::from_static_str_unchecked(#iface_name), ::std::collections::HashMap::new(), - vec![#member_name], + ::std::borrow::Cow::Borrowed(&[#member_name]), ).await } );