diff --git a/examples/examples/z_pub.rs b/examples/examples/z_pub.rs index 4ff177c32a..3b125419cd 100644 --- a/examples/examples/z_pub.rs +++ b/examples/examples/z_pub.rs @@ -14,7 +14,7 @@ use std::time::Duration; use clap::Parser; -use zenoh::{bytes::Encoding, key_expr::KeyExpr, prelude::*, Config}; +use zenoh::{bytes::Encoding, key_expr::KeyExpr, Config}; use zenoh_examples::CommonArgs; #[tokio::main] diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/align_queryable.rs b/plugins/zenoh-plugin-storage-manager/src/replica/align_queryable.rs index 737ce79144..1baad55db6 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/align_queryable.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/align_queryable.rs @@ -21,8 +21,8 @@ use std::{ }; use zenoh::{ - internal::Value, key_expr::OwnedKeyExpr, prelude::*, query::Parameters, sample::Sample, - time::Timestamp, Session, + internal::Value, key_expr::OwnedKeyExpr, query::Parameters, sample::Sample, time::Timestamp, + Session, }; use super::{digest::*, Snapshotter}; diff --git a/zenoh/src/api/publisher.rs b/zenoh/src/api/publisher.rs index faa2e4eca6..33f04d0cda 100644 --- a/zenoh/src/api/publisher.rs +++ b/zenoh/src/api/publisher.rs @@ -12,8 +12,6 @@ // ZettaScale Zenoh Team, // -#[cfg(feature = "unstable")] -use std::mem::size_of; use std::{ convert::TryFrom, fmt, @@ -765,7 +763,7 @@ where Handler: IntoHandler<'static, MatchingStatus> + Send, Handler::Handler: Send, { - type To = ZResult>; + type To = ZResult>; } #[zenoh_macros::unstable] @@ -784,7 +782,8 @@ where zlock!(self.publisher.matching_listeners).insert(state.id); Ok(MatchingListener { inner: MatchingListenerInner { - publisher: self.publisher.clone(), + session: self.publisher.session.clone(), + matching_listeners: self.publisher.matching_listeners.clone(), state, undeclare_on_drop: self.undeclare_on_drop, }, @@ -828,8 +827,9 @@ impl fmt::Debug for MatchingListenerState { } #[zenoh_macros::unstable] -pub(crate) struct MatchingListenerInner<'a> { - pub(crate) publisher: Publisher<'a>, +pub(crate) struct MatchingListenerInner { + pub(crate) session: WeakSession, + pub(crate) matching_listeners: Arc>>, pub(crate) state: Arc, pub(crate) undeclare_on_drop: bool, } @@ -860,13 +860,13 @@ pub(crate) struct MatchingListenerInner<'a> { /// # } /// ``` #[zenoh_macros::unstable] -pub struct MatchingListener<'a, Handler> { - pub(crate) inner: MatchingListenerInner<'a>, +pub struct MatchingListener { + pub(crate) inner: MatchingListenerInner, pub(crate) handler: Handler, } #[zenoh_macros::unstable] -impl<'a, Handler> MatchingListener<'a, Handler> { +impl MatchingListener { /// Undeclare the [`MatchingListener`]. /// /// # Examples @@ -882,7 +882,7 @@ impl<'a, Handler> MatchingListener<'a, Handler> { /// # } /// ``` #[inline] - pub fn undeclare(self) -> MatchingListenerUndeclaration<'a, Handler> + pub fn undeclare(self) -> MatchingListenerUndeclaration where Handler: Send, { @@ -892,17 +892,16 @@ impl<'a, Handler> MatchingListener<'a, Handler> { fn undeclare_impl(&mut self) -> ZResult<()> { // set the flag first to avoid double panic if this function panic self.inner.undeclare_on_drop = false; - zlock!(self.inner.publisher.matching_listeners).remove(&self.inner.state.id); + zlock!(self.inner.matching_listeners).remove(&self.inner.state.id); self.inner - .publisher .session .undeclare_matches_listener_inner(self.inner.state.id) } } #[zenoh_macros::unstable] -impl<'a, Handler: Send> UndeclarableSealed<()> for MatchingListener<'a, Handler> { - type Undeclaration = MatchingListenerUndeclaration<'a, Handler>; +impl UndeclarableSealed<()> for MatchingListener { + type Undeclaration = MatchingListenerUndeclaration; fn undeclare_inner(self, _: ()) -> Self::Undeclaration { MatchingListenerUndeclaration(self) @@ -910,7 +909,7 @@ impl<'a, Handler: Send> UndeclarableSealed<()> for MatchingListener<'a, Handler> } #[zenoh_macros::unstable] -impl std::ops::Deref for MatchingListener<'_, Handler> { +impl std::ops::Deref for MatchingListener { type Target = Handler; fn deref(&self) -> &Self::Target { @@ -918,29 +917,29 @@ impl std::ops::Deref for MatchingListener<'_, Handler> { } } #[zenoh_macros::unstable] -impl std::ops::DerefMut for MatchingListener<'_, Handler> { +impl std::ops::DerefMut for MatchingListener { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.handler } } #[zenoh_macros::unstable] -pub struct MatchingListenerUndeclaration<'a, Handler>(MatchingListener<'a, Handler>); +pub struct MatchingListenerUndeclaration(MatchingListener); #[zenoh_macros::unstable] -impl Resolvable for MatchingListenerUndeclaration<'_, Handler> { +impl Resolvable for MatchingListenerUndeclaration { type To = ZResult<()>; } #[zenoh_macros::unstable] -impl Wait for MatchingListenerUndeclaration<'_, Handler> { +impl Wait for MatchingListenerUndeclaration { fn wait(mut self) -> ::To { self.0.undeclare_impl() } } #[zenoh_macros::unstable] -impl IntoFuture for MatchingListenerUndeclaration<'_, Handler> { +impl IntoFuture for MatchingListenerUndeclaration { type Output = ::To; type IntoFuture = Ready<::To>; diff --git a/zenoh/tests/qos.rs b/zenoh/tests/qos.rs index 8d7d7e7322..2ba3226310 100644 --- a/zenoh/tests/qos.rs +++ b/zenoh/tests/qos.rs @@ -15,7 +15,6 @@ use std::time::Duration; use zenoh::{ bytes::Encoding, - prelude::*, qos::{CongestionControl, Priority}, }; use zenoh_core::ztimeout; diff --git a/zenoh/tests/routing.rs b/zenoh/tests/routing.rs index 1023584c70..8b272b274a 100644 --- a/zenoh/tests/routing.rs +++ b/zenoh/tests/routing.rs @@ -22,7 +22,6 @@ use std::{ use tokio_util::sync::CancellationToken; use zenoh::{ config::{ModeDependentValue, WhatAmI, WhatAmIMatcher}, - prelude::*, qos::CongestionControl, Config, Result, Session, }; diff --git a/zenoh/tests/session.rs b/zenoh/tests/session.rs index 7515eefc49..a1e374e379 100644 --- a/zenoh/tests/session.rs +++ b/zenoh/tests/session.rs @@ -23,9 +23,7 @@ use std::{ use zenoh::internal::runtime::{Runtime, RuntimeBuilder}; #[cfg(feature = "unstable")] use zenoh::pubsub::Reliability; -use zenoh::{ - config, key_expr::KeyExpr, prelude::*, qos::CongestionControl, sample::SampleKind, Session, -}; +use zenoh::{config, key_expr::KeyExpr, qos::CongestionControl, sample::SampleKind, Session}; use zenoh_core::ztimeout; #[cfg(not(feature = "unstable"))] use zenoh_protocol::core::Reliability; diff --git a/zenoh/tests/shm.rs b/zenoh/tests/shm.rs index 0febac2eaa..d223b1d4a6 100644 --- a/zenoh/tests/shm.rs +++ b/zenoh/tests/shm.rs @@ -22,7 +22,6 @@ use std::{ use zenoh::{ config, - prelude::*, pubsub::Reliability, qos::CongestionControl, shm::{ diff --git a/zenoh/tests/unicity.rs b/zenoh/tests/unicity.rs index 49663249ad..657edae1c9 100644 --- a/zenoh/tests/unicity.rs +++ b/zenoh/tests/unicity.rs @@ -24,7 +24,6 @@ use zenoh::{ config, config::{EndPoint, WhatAmI}, key_expr::KeyExpr, - prelude::*, qos::CongestionControl, Session, };