Commit 35db7927 authored by Zeeshan Ali's avatar Zeeshan Ali
Browse files

Merge branch 'lifetime-cleanup' into 'main'

Various lifetime annotations cleanups

See merge request !298
parents c605097f 20d8c1eb
Pipeline #320175 passed with stages
in 6 minutes and 10 seconds
......@@ -597,8 +597,8 @@ impl std::ops::Drop for SignalStream<'_> {
}
}
impl<'azync, 'sync: 'azync> From<crate::Proxy<'sync>> for Proxy<'azync> {
fn from(proxy: crate::Proxy<'sync>) -> Self {
impl<'a> From<crate::Proxy<'a>> for Proxy<'a> {
fn from(proxy: crate::Proxy<'a>) -> Self {
proxy.into_inner()
}
}
......
......@@ -243,7 +243,7 @@ impl<'a> Proxy<'a> {
}
/// Get a reference to the underlying async Proxy.
pub fn inner(&self) -> &azync::Proxy<'_> {
pub fn inner(&self) -> &azync::Proxy<'a> {
&self.azync
}
......@@ -265,13 +265,13 @@ impl<'a> Proxy<'a> {
}
}
impl<'asref, 'p: 'asref> std::convert::AsRef<Proxy<'asref>> for Proxy<'p> {
fn as_ref(&self) -> &Proxy<'asref> {
impl<'a> std::convert::AsRef<Proxy<'a>> for Proxy<'a> {
fn as_ref(&self) -> &Proxy<'a> {
&self
}
}
impl<'p, 'a: 'p> From<azync::Proxy<'a>> for Proxy<'p> {
impl<'a> From<azync::Proxy<'a>> for Proxy<'a> {
fn from(proxy: azync::Proxy<'a>) -> Self {
Self {
conn: proxy.connection().clone().into(),
......
......@@ -15,7 +15,7 @@ struct ProxyKey<'key> {
path: ObjectPath<'key>,
}
impl<'p, P> From<&P> for ProxyKey<'_>
impl<'p, P> From<&P> for ProxyKey<'static>
where
P: AsRef<Proxy<'p>>,
{
......@@ -36,10 +36,10 @@ where
}
}
impl<'key> TryFrom<&'key MessageHeader<'_>> for ProxyKey<'key> {
impl<'key> TryFrom<&'key MessageHeader<'key>> for ProxyKey<'key> {
type Error = Error;
fn try_from(hdr: &'key MessageHeader<'_>) -> Result<Self> {
fn try_from(hdr: &'key MessageHeader<'key>) -> Result<Self> {
match (hdr.interface()?, hdr.path()?.cloned(), hdr.sender()?) {
(Some(interface), Some(path), Some(destination)) => Ok(ProxyKey {
interface: Cow::from(interface),
......@@ -54,14 +54,14 @@ impl<'key> TryFrom<&'key MessageHeader<'_>> for ProxyKey<'key> {
/// Receives signals for [`Proxy`] instances.
///
/// Use this to receive signals on a given connection for a bunch of proxies at the same time.
pub struct SignalReceiver<'r, 'p> {
pub struct SignalReceiver<'a> {
conn: Connection,
proxies: HashMap<ProxyKey<'static>, &'r Proxy<'p>>,
proxies: HashMap<ProxyKey<'static>, &'a Proxy<'a>>,
}
assert_impl_all!(SignalReceiver<'_, '_>: Send, Sync, Unpin);
assert_impl_all!(SignalReceiver<'_>: Send, Sync, Unpin);
impl<'r, 'p> SignalReceiver<'r, 'p> {
impl<'a> SignalReceiver<'a> {
/// Create a new `SignalReceiver` instance.
pub fn new(conn: Connection) -> Self {
Self {
......@@ -76,7 +76,7 @@ impl<'r, 'p> SignalReceiver<'r, 'p> {
}
/// Get a iterator for all the proxies in this receiver.
pub fn proxies(&self) -> impl Iterator<Item = &&Proxy<'_>> {
pub fn proxies(&self) -> impl Iterator<Item = &&Proxy<'a>> {
self.proxies.values()
}
......@@ -86,7 +86,7 @@ impl<'r, 'p> SignalReceiver<'r, 'p> {
///
/// This method will panic if you try to add a proxy with a different associated connection than
/// the one associated with this receiver.
pub fn receive_for<'a: 'p, 'b: 'r, P>(&mut self, proxy: &'b P) -> Result<()>
pub fn receive_for<P>(&mut self, proxy: &'a P) -> Result<()>
where
P: AsRef<Proxy<'a>>,
{
......
......@@ -161,7 +161,7 @@ pub fn create_proxy(args: &[NestedMeta], input: &ItemTrait, azync: bool) -> Toke
}
/// The reference to the underlying `zbus::Proxy`.
pub fn inner(&self) -> &#proxy_struct {
pub fn inner(&self) -> &#proxy_struct<'c> {
&self.0
}
......@@ -250,12 +250,12 @@ fn gen_proxy_method_call(
let (_, ty_generics, where_clause) = m.sig.generics.split_for_impl();
let signature = if where_clause.is_some() {
quote! {
fn #method#ty_generics(#inputs) -> ::#zbus::Result<#proxy<'_>>
fn #method#ty_generics(#inputs) -> ::#zbus::Result<#proxy<'c>>
#where_clause,
}
} else {
quote! {
fn #method(#inputs) -> ::#zbus::Result<#proxy<'_>>
fn #method(#inputs) -> ::#zbus::Result<#proxy<'c>>
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment