diff --git a/commons/zenoh-core/src/lib.rs b/commons/zenoh-core/src/lib.rs index 28249c7a67..1380680260 100644 --- a/commons/zenoh-core/src/lib.rs +++ b/commons/zenoh-core/src/lib.rs @@ -74,6 +74,7 @@ impl Resolve for T where } // Closure to wait +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct ResolveClosure(C) where To: Sized + Send, @@ -120,6 +121,7 @@ where } // Future to wait +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct ResolveFuture(F) where To: Sized + Send, diff --git a/zenoh-ext/src/publication_cache.rs b/zenoh-ext/src/publication_cache.rs index 78b951436e..7ae440b02c 100644 --- a/zenoh-ext/src/publication_cache.rs +++ b/zenoh-ext/src/publication_cache.rs @@ -27,6 +27,7 @@ use zenoh_result::{bail, ZResult}; use zenoh_util::core::ResolveFuture; /// The builder of PublicationCache, allowing to configure it. +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct PublicationCacheBuilder<'a, 'b, 'c> { session: SessionRef<'a>, pub_key_expr: ZResult>, diff --git a/zenoh-ext/src/querying_subscriber.rs b/zenoh-ext/src/querying_subscriber.rs index 806a55e25c..33f3bc6153 100644 --- a/zenoh-ext/src/querying_subscriber.rs +++ b/zenoh-ext/src/querying_subscriber.rs @@ -27,6 +27,7 @@ use zenoh::SessionRef; use zenoh_core::{zlock, AsyncResolve, Resolvable, SyncResolve}; /// The builder of [`FetchingSubscriber`], allowing to configure it. +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct QueryingSubscriberBuilder<'a, 'b, KeySpace, Handler> { pub(crate) session: SessionRef<'a>, pub(crate) key_expr: ZResult>, @@ -340,6 +341,7 @@ struct InnerState { } /// The builder of [`FetchingSubscriber`], allowing to configure it. +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct FetchingSubscriberBuilder< 'a, 'b, @@ -850,6 +852,7 @@ impl Drop for RepliesHandler { /// .unwrap(); /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct FetchBuilder< Fetch: FnOnce(Box) -> ZResult<()>, TryIntoSample, diff --git a/zenoh/src/info.rs b/zenoh/src/info.rs index b8b3d0bd88..28579b3d6c 100644 --- a/zenoh/src/info.rs +++ b/zenoh/src/info.rs @@ -31,6 +31,7 @@ use zenoh_protocol::core::{WhatAmI, ZenohId}; /// let zid = session.info().zid().res().await; /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct ZidBuilder<'a> { pub(crate) session: SessionRef<'a>, } @@ -67,6 +68,7 @@ impl<'a> AsyncResolve for ZidBuilder<'a> { /// while let Some(router_zid) = routers_zid.next() {} /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct RoutersZidBuilder<'a> { pub(crate) session: SessionRef<'a>, } @@ -112,6 +114,7 @@ impl<'a> AsyncResolve for RoutersZidBuilder<'a> { /// while let Some(peer_zid) = peers_zid.next() {} /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct PeersZidBuilder<'a> { pub(crate) session: SessionRef<'a>, } diff --git a/zenoh/src/key_expr.rs b/zenoh/src/key_expr.rs index ad41c30457..b3e0c4b87c 100644 --- a/zenoh/src/key_expr.rs +++ b/zenoh/src/key_expr.rs @@ -585,6 +585,7 @@ impl<'a> Undeclarable<&'a Session, KeyExprUndeclaration<'a>> for KeyExpr<'a> { /// session.undeclare(key_expr).res().await.unwrap(); /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct KeyExprUndeclaration<'a> { session: &'a Session, expr: KeyExpr<'a>, diff --git a/zenoh/src/lib.rs b/zenoh/src/lib.rs index dbcc3b5827..d77a205d50 100644 --- a/zenoh/src/lib.rs +++ b/zenoh/src/lib.rs @@ -308,6 +308,7 @@ pub fn init(runtime: Runtime) -> InitBuilder { } /// A builder returned by [`init`] and used to initialize a Session with an existing Runtime. +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] #[doc(hidden)] #[zenoh_macros::unstable] pub struct InitBuilder { diff --git a/zenoh/src/liveliness.rs b/zenoh/src/liveliness.rs index be39e3b7f6..1e36cb8f69 100644 --- a/zenoh/src/liveliness.rs +++ b/zenoh/src/liveliness.rs @@ -211,6 +211,7 @@ impl<'a> Liveliness<'a> { /// .unwrap(); /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] #[zenoh_macros::unstable] #[derive(Debug)] pub struct LivelinessTokenBuilder<'a, 'b> { @@ -310,6 +311,7 @@ pub struct LivelinessToken<'a> { /// liveliness.undeclare().res().await.unwrap(); /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] #[zenoh_macros::unstable] pub struct LivelinessTokenUndeclaration<'a> { token: LivelinessToken<'a>, @@ -595,6 +597,7 @@ where /// } /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] #[derive(Debug)] pub struct LivelinessGetBuilder<'a, 'b, Handler> { pub(crate) session: &'a Session, diff --git a/zenoh/src/publication.rs b/zenoh/src/publication.rs index d88fa4b9c9..3a69c19f8f 100644 --- a/zenoh/src/publication.rs +++ b/zenoh/src/publication.rs @@ -69,6 +69,7 @@ pub type DeleteBuilder<'a, 'b> = PutBuilder<'a, 'b>; /// .unwrap(); /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] #[derive(Debug, Clone)] pub struct PutBuilder<'a, 'b> { pub(crate) publisher: PublisherBuilder<'a, 'b>, @@ -362,6 +363,7 @@ impl<'a> Undeclarable<(), PublisherUndeclaration<'a>> for Publisher<'a> { /// publisher.undeclare().res().await.unwrap(); /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct PublisherUndeclaration<'a> { publisher: Publisher<'a>, } @@ -404,6 +406,7 @@ impl Drop for Publisher<'_> { /// A [`Resolvable`] returned by [`Publisher::put()`](Publisher::put), /// [`Publisher::delete()`](Publisher::delete) and [`Publisher::write()`](Publisher::write). +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct Publication<'a> { publisher: &'a Publisher<'a>, value: Value, @@ -520,6 +523,7 @@ where /// .unwrap(); /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] #[derive(Debug)] pub struct PublisherBuilder<'a, 'b: 'a> { pub(crate) session: SessionRef<'a>, diff --git a/zenoh/src/query.rs b/zenoh/src/query.rs index c55822bac6..18cb7e882e 100644 --- a/zenoh/src/query.rs +++ b/zenoh/src/query.rs @@ -114,6 +114,7 @@ pub(crate) struct QueryState { /// } /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] #[derive(Debug)] pub struct GetBuilder<'a, 'b, Handler> { pub(crate) session: &'a Session, diff --git a/zenoh/src/queryable.rs b/zenoh/src/queryable.rs index ed0560d759..d1edf8407d 100644 --- a/zenoh/src/queryable.rs +++ b/zenoh/src/queryable.rs @@ -280,6 +280,7 @@ impl<'a> Undeclarable<(), QueryableUndeclaration<'a>> for CallbackQueryable<'a> /// queryable.undeclare().res().await.unwrap(); /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct QueryableUndeclaration<'a> { queryable: CallbackQueryable<'a>, } @@ -325,8 +326,8 @@ impl Drop for CallbackQueryable<'_> { /// let queryable = session.declare_queryable("key/expression").res().await.unwrap(); /// # }) /// ``` -#[derive(Debug)] #[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] +#[derive(Debug)] pub struct QueryableBuilder<'a, 'b, Handler> { pub(crate) session: SessionRef<'a>, pub(crate) key_expr: ZResult>, diff --git a/zenoh/src/subscriber.rs b/zenoh/src/subscriber.rs index a8a7914f82..7258833d28 100644 --- a/zenoh/src/subscriber.rs +++ b/zenoh/src/subscriber.rs @@ -213,6 +213,7 @@ impl<'a> Undeclarable<(), SubscriberUndeclaration<'a>> for SubscriberInner<'a> { /// subscriber.undeclare().res().await.unwrap(); /// # }) /// ``` +#[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] pub struct SubscriberUndeclaration<'a> { subscriber: SubscriberInner<'a>, } @@ -297,8 +298,8 @@ impl From for Mode { /// .unwrap(); /// # }) /// ``` -#[derive(Debug)] #[must_use = "Resolvables do nothing unless you resolve them using the `res` method from either `SyncResolve` or `AsyncResolve`"] +#[derive(Debug)] pub struct SubscriberBuilder<'a, 'b, Mode, Handler> { #[cfg(feature = "unstable")] pub session: SessionRef<'a>,