diff --git a/zenoh-ext/src/advanced_cache.rs b/zenoh-ext/src/advanced_cache.rs index 70132445e2..7c7bdf9f34 100644 --- a/zenoh-ext/src/advanced_cache.rs +++ b/zenoh-ext/src/advanced_cache.rs @@ -64,6 +64,7 @@ impl Default for RepliesConfig { impl QoSBuilderTrait for RepliesConfig { #[allow(unused_mut)] #[zenoh_macros::unstable] + /// Changes the [`CongestionControl`] to apply when routing the data. fn congestion_control(mut self, congestion_control: CongestionControl) -> Self { self.congestion_control = congestion_control; self @@ -71,6 +72,7 @@ impl QoSBuilderTrait for RepliesConfig { #[allow(unused_mut)] #[zenoh_macros::unstable] + /// Changes the [`Priority`] to apply when routing the data. fn priority(mut self, priority: Priority) -> Self { self.priority = priority; self @@ -78,6 +80,10 @@ impl QoSBuilderTrait for RepliesConfig { #[allow(unused_mut)] #[zenoh_macros::unstable] + /// Changes the Express policy to apply when routing the data. + /// + /// When express is set to `true`, then the message will not be batched. + /// This usually has a positive impact on latency but a negative impact on throughput. fn express(mut self, is_express: bool) -> Self { self.is_express = is_express; self diff --git a/zenoh-ext/src/advanced_publisher.rs b/zenoh-ext/src/advanced_publisher.rs index 39dfe42c6b..73d5fd5e34 100644 --- a/zenoh-ext/src/advanced_publisher.rs +++ b/zenoh-ext/src/advanced_publisher.rs @@ -220,6 +220,7 @@ impl<'a, 'b, 'c> AdvancedPublisherBuilder<'a, 'b, 'c> { #[zenoh_macros::internal_trait] #[zenoh_macros::unstable] impl EncodingBuilderTrait for AdvancedPublisherBuilder<'_, '_, '_> { + /// Set the [`Encoding`] #[zenoh_macros::unstable] fn encoding>(self, encoding: T) -> Self { Self { @@ -232,7 +233,7 @@ impl EncodingBuilderTrait for AdvancedPublisherBuilder<'_, '_, '_> { #[zenoh_macros::internal_trait] #[zenoh_macros::unstable] impl QoSBuilderTrait for AdvancedPublisherBuilder<'_, '_, '_> { - /// Changes the [`zenoh::qos::CongestionControl`] to apply when routing the data. + /// Changes the [`CongestionControl`] to apply when routing the data. #[inline] #[zenoh_macros::unstable] fn congestion_control(self, congestion_control: CongestionControl) -> Self { @@ -242,7 +243,7 @@ impl QoSBuilderTrait for AdvancedPublisherBuilder<'_, '_, '_> { } } - /// Changes the [`zenoh::qos::Priority`] of the written data. + /// Changes the [`Priority`] to apply when routing the data. #[inline] #[zenoh_macros::unstable] fn priority(self, priority: Priority) -> Self { @@ -686,6 +687,7 @@ pub struct AdvancedPublicationBuilder<'a, P> { #[zenoh_macros::internal_trait] #[zenoh_macros::unstable] impl EncodingBuilderTrait for AdvancedPublicationBuilder<'_, PublicationBuilderPut> { + /// Set the [`Encoding`] #[zenoh_macros::unstable] fn encoding>(self, encoding: T) -> Self { Self { @@ -699,6 +701,7 @@ impl EncodingBuilderTrait for AdvancedPublicationBuilder<'_, PublicationBuilderP #[zenoh_macros::unstable] impl

SampleBuilderTrait for AdvancedPublicationBuilder<'_, P> { #[zenoh_macros::unstable] + /// Sets an optional [`SourceInfo`](zenoh::sample::SourceInfo) to be sent along with the publication. fn source_info>>(self, source_info: TS) -> Self { Self { builder: self.builder.source_info(source_info), @@ -706,6 +709,10 @@ impl

SampleBuilderTrait for AdvancedPublicationBuilder<'_, P> { } } #[zenoh_macros::unstable] + /// Sets an optional attachment to be sent along with the publication. + /// + /// The argument is converted via [`OptionZBytes`], which supports both `T: Into` + /// and `Option` where `T: Into`. fn attachment>(self, attachment: TA) -> Self { let attachment: OptionZBytes = attachment.into(); Self { @@ -718,6 +725,7 @@ impl

SampleBuilderTrait for AdvancedPublicationBuilder<'_, P> { #[zenoh_macros::internal_trait] #[zenoh_macros::unstable] impl

TimestampBuilderTrait for AdvancedPublicationBuilder<'_, P> { + /// Sets an optional timestamp to be sent along with the publication. #[zenoh_macros::unstable] fn timestamp>>(self, timestamp: TS) -> Self { Self { diff --git a/zenoh/src/api/builders/publisher.rs b/zenoh/src/api/builders/publisher.rs index 9bfe8363b2..fc7c5f7ab5 100644 --- a/zenoh/src/api/builders/publisher.rs +++ b/zenoh/src/api/builders/publisher.rs @@ -116,7 +116,7 @@ impl QoSBuilderTrait for PublicationBuilder, T> { } } - /// Changes the [`Priority`](crate::qos::Priority) of the written data. + /// Changes the [`Priority`](crate::qos::Priority) when routing the data. #[inline] fn priority(self, priority: Priority) -> Self { Self { diff --git a/zenoh/src/api/builders/querier.rs b/zenoh/src/api/builders/querier.rs index f99f0f7bcb..c138dece14 100644 --- a/zenoh/src/api/builders/querier.rs +++ b/zenoh/src/api/builders/querier.rs @@ -86,16 +86,21 @@ pub struct QuerierBuilder<'a, 'b> { #[zenoh_macros::internal_trait] impl QoSBuilderTrait for QuerierBuilder<'_, '_> { + /// Changes the [`CongestionControl`](crate::qos::CongestionControl) to apply when routing the request. fn congestion_control(self, congestion_control: CongestionControl) -> Self { let qos = self.qos.congestion_control(congestion_control); Self { qos, ..self } } + /// Changes the [`Priority`](crate::qos::Priority) of the request. fn priority(self, priority: Priority) -> Self { let qos = self.qos.priority(priority); Self { qos, ..self } } - + /// Changes the Express policy to apply when routing the request. + /// + /// When express is set to `true`, then the message will not be batched. + /// This usually has a positive impact on latency but a negative impact on throughput. fn express(self, is_express: bool) -> Self { let qos = self.qos.express(is_express); Self { qos, ..self } @@ -287,6 +292,7 @@ impl CancellationTokenBuilderTrait for QuerierGetBuilder<'_, '_, Handle #[zenoh_macros::internal_trait] impl SampleBuilderTrait for QuerierGetBuilder<'_, '_, Handler> { + /// Sets an optional [`SourceInfo`](crate::sample::SourceInfo) to be sent along with the query request. #[zenoh_macros::unstable] fn source_info>>(self, source_info: T) -> Self { Self { @@ -294,7 +300,9 @@ impl SampleBuilderTrait for QuerierGetBuilder<'_, '_, Handler> { ..self } } - + /// Sets an optional attachment to be sent along with the query request. + /// The method accepts both values convertible to [`ZBytes`](crate::bytes::ZBytes) + /// and optional values of such types (`Option` where `T: Into`). fn attachment>(self, attachment: T) -> Self { let attachment: OptionZBytes = attachment.into(); Self { @@ -306,6 +314,7 @@ impl SampleBuilderTrait for QuerierGetBuilder<'_, '_, Handler> { #[zenoh_macros::internal_trait] impl EncodingBuilderTrait for QuerierGetBuilder<'_, '_, Handler> { + /// Set the [`Encoding`] fn encoding>(self, encoding: T) -> Self { let mut value = self.value.unwrap_or_default(); value.1 = encoding.into(); diff --git a/zenoh/src/api/builders/query.rs b/zenoh/src/api/builders/query.rs index 00f48e59c8..287742ea05 100644 --- a/zenoh/src/api/builders/query.rs +++ b/zenoh/src/api/builders/query.rs @@ -85,6 +85,7 @@ pub struct SessionGetBuilder<'a, 'b, Handler> { #[zenoh_macros::internal_trait] impl SampleBuilderTrait for SessionGetBuilder<'_, '_, Handler> { #[zenoh_macros::unstable] + /// Sets an optional [`SourceInfo`](crate::sample::SourceInfo) to be sent along with the request/query. fn source_info>>(self, source_info: T) -> Self { Self { source_info: source_info.into(), @@ -92,6 +93,8 @@ impl SampleBuilderTrait for SessionGetBuilder<'_, '_, Handler> { } } + /// Sets an optional attachment to be sent along with the request/query. + /// The method accepts both `T` where `T: Into` and `Option` where `T: Into` (see [`OptionZBytes`](crate::bytes::OptionZBytes)). fn attachment>(self, attachment: T) -> Self { let attachment: OptionZBytes = attachment.into(); Self { @@ -103,16 +106,22 @@ impl SampleBuilderTrait for SessionGetBuilder<'_, '_, Handler> { #[zenoh_macros::internal_trait] impl QoSBuilderTrait for SessionGetBuilder<'_, '_, Handler> { + /// Changes the [`CongestionControl`](crate::qos::CongestionControl) to apply when routing the request. fn congestion_control(self, congestion_control: CongestionControl) -> Self { let qos = self.qos.congestion_control(congestion_control); Self { qos, ..self } } + /// Changes the [`Priority`](crate::qos::Priority) of the request. fn priority(self, priority: Priority) -> Self { let qos = self.qos.priority(priority); Self { qos, ..self } } + /// Changes the Express policy to apply when routing the request. + /// + /// When express is set to `true`, then the message will not be batched. + /// This usually has a positive impact on latency but a negative impact on throughput. fn express(self, is_express: bool) -> Self { let qos = self.qos.express(is_express); Self { qos, ..self } @@ -121,6 +130,7 @@ impl QoSBuilderTrait for SessionGetBuilder<'_, '_, Handler> { #[zenoh_macros::internal_trait] impl EncodingBuilderTrait for SessionGetBuilder<'_, '_, Handler> { + /// Set the [`Encoding`] fn encoding>(self, encoding: T) -> Self { let mut value = self.value.unwrap_or_default(); value.1 = encoding.into(); diff --git a/zenoh/src/api/builders/reply.rs b/zenoh/src/api/builders/reply.rs index aeac50786b..b16144a1bd 100644 --- a/zenoh/src/api/builders/reply.rs +++ b/zenoh/src/api/builders/reply.rs @@ -111,6 +111,7 @@ impl<'a, 'b> ReplyBuilder<'a, 'b, ReplyBuilderDelete> { #[zenoh_macros::internal_trait] impl TimestampBuilderTrait for ReplyBuilder<'_, '_, T> { + /// Sets an optional timestamp to be sent along with the reply/response. fn timestamp>>(self, timestamp: U) -> Self { Self { timestamp: timestamp.into(), @@ -121,6 +122,8 @@ impl TimestampBuilderTrait for ReplyBuilder<'_, '_, T> { #[zenoh_macros::internal_trait] impl SampleBuilderTrait for ReplyBuilder<'_, '_, T> { + /// Sets an optional attachment to be sent along with the reply/response. + /// The method accepts any `T` where `T: Into` or `Option`. fn attachment>(self, attachment: U) -> Self { let attachment: OptionZBytes = attachment.into(); Self { @@ -130,6 +133,7 @@ impl SampleBuilderTrait for ReplyBuilder<'_, '_, T> { } #[cfg(feature = "unstable")] + /// Sets an optional [`SourceInfo`](crate::sample::SourceInfo) to be sent along with the reply/response. fn source_info>>(self, source_info: TS) -> Self { Self { source_info: source_info.into(), @@ -150,6 +154,10 @@ impl QoSBuilderTrait for ReplyBuilder<'_, '_, T> { self } + /// Changes the Express policy to apply when routing the reply. + /// + /// When express is set to `true`, then the message will not be batched. + /// This usually has a positive impact on latency but a negative impact on throughput. fn express(self, is_express: bool) -> Self { let qos = self.qos.express(is_express); Self { qos, ..self } @@ -158,6 +166,7 @@ impl QoSBuilderTrait for ReplyBuilder<'_, '_, T> { #[zenoh_macros::internal_trait] impl EncodingBuilderTrait for ReplyBuilder<'_, '_, ReplyBuilderPut> { + /// Set the [`Encoding`] fn encoding>(self, encoding: T) -> Self { Self { kind: ReplyBuilderPut { @@ -243,6 +252,7 @@ impl<'a> ReplyErrBuilder<'a> { #[zenoh_macros::internal_trait] impl EncodingBuilderTrait for ReplyErrBuilder<'_> { + /// Set the [`Encoding`] fn encoding>(self, encoding: T) -> Self { Self { encoding: encoding.into(), diff --git a/zenoh/src/api/builders/sample.rs b/zenoh/src/api/builders/sample.rs index 23de0a0619..b530e8098b 100644 --- a/zenoh/src/api/builders/sample.rs +++ b/zenoh/src/api/builders/sample.rs @@ -33,9 +33,9 @@ use crate::pubsub::{ #[cfg(feature = "unstable")] use crate::sample::SourceInfo; pub trait QoSBuilderTrait { - /// Change the `congestion_control` to apply when routing the data. + /// Changes the [`CongestionControl`](crate::qos::CongestionControl) to apply when routing the data. fn congestion_control(self, congestion_control: CongestionControl) -> Self; - /// Change the priority of the written data. + /// Changes the [`Priority`](crate::qos::Priority) when routing the data. fn priority(self, priority: Priority) -> Self; /// Change the `express` policy to apply when routing the data. /// When express is set to `true`, then the message will not be batched. @@ -49,10 +49,12 @@ pub trait TimestampBuilderTrait { } pub trait SampleBuilderTrait { - /// Attach source information + /// Sets an optional [`SourceInfo`](crate::sample::SourceInfo) to be sent along with the publication. #[zenoh_macros::unstable] fn source_info>>(self, source_info: T) -> Self; - /// Attach user-provided data in key-value format + /// Sets an optional attachment to be sent along with the publication. + /// The method accepts any `T` where `T: Into` or `Option` where `T: Into`. + /// See [`OptionZBytes`](crate::api::bytes::OptionZBytes) for the exact accepted forms. fn attachment>(self, attachment: T) -> Self; } @@ -184,6 +186,7 @@ impl SampleBuilder { #[zenoh_macros::internal_trait] impl TimestampBuilderTrait for SampleBuilder { + /// Sets an optional timestamp to be sent along with the publication. fn timestamp>>(self, timestamp: U) -> Self { Self { sample: Sample { @@ -198,6 +201,7 @@ impl TimestampBuilderTrait for SampleBuilder { #[zenoh_macros::internal_trait] impl SampleBuilderTrait for SampleBuilder { #[zenoh_macros::unstable] + /// Sets an optional [`SourceInfo`](crate::sample::SourceInfo) to be sent along with the publication. fn source_info>>(self, source_info: S) -> Self { Self { sample: Sample { @@ -208,6 +212,8 @@ impl SampleBuilderTrait for SampleBuilder { } } + /// Sets an optional attachment to be sent along with the publication. + /// The method accepts both `Into` and `Option>`. fn attachment>(self, attachment: U) -> Self { let attachment: OptionZBytes = attachment.into(); Self { @@ -222,6 +228,7 @@ impl SampleBuilderTrait for SampleBuilder { #[zenoh_macros::internal_trait] impl QoSBuilderTrait for SampleBuilder { + /// Changes the [`CongestionControl`](crate::qos::CongestionControl) to apply when routing the data/publication/sample. fn congestion_control(self, congestion_control: CongestionControl) -> Self { let qos: QoSBuilder = self.sample.qos.into(); let qos = qos.congestion_control(congestion_control).into(); @@ -230,6 +237,7 @@ impl QoSBuilderTrait for SampleBuilder { _t: PhantomData::, } } + /// Changes the [`Priority`](crate::qos::Priority) to apply when routing the data. fn priority(self, priority: Priority) -> Self { let qos: QoSBuilder = self.sample.qos.into(); let qos = qos.priority(priority).into(); @@ -238,6 +246,10 @@ impl QoSBuilderTrait for SampleBuilder { _t: PhantomData::, } } + /// Changes the Express policy to apply when routing the data. + /// + /// When express is set to `true`, then the message will not be batched. + /// This usually has a positive impact on latency but a negative impact on throughput. fn express(self, is_express: bool) -> Self { let qos: QoSBuilder = self.sample.qos.into(); let qos = qos.express(is_express).into(); @@ -250,6 +262,7 @@ impl QoSBuilderTrait for SampleBuilder { #[zenoh_macros::internal_trait] impl EncodingBuilderTrait for SampleBuilder { + /// Set the [`Encoding`] fn encoding>(self, encoding: T) -> Self { Self { sample: Sample { diff --git a/zenoh/src/api/publisher.rs b/zenoh/src/api/publisher.rs index a72fbad563..d2fdedf895 100644 --- a/zenoh/src/api/publisher.rs +++ b/zenoh/src/api/publisher.rs @@ -71,6 +71,8 @@ impl fmt::Debug for PublisherState { } /// A publisher that allows sending data through a stream. +/// A Publisher is declared by a [`Session`](crate::api::session::Session) for a given key expression +/// with method [`Session::declare_publisher`](crate::api::session::Session::declare_publisher). /// /// Publishers are automatically undeclared when dropped. /// diff --git a/zenoh/src/api/querier.rs b/zenoh/src/api/querier.rs index 05f57d5cbd..2a03d92de7 100644 --- a/zenoh/src/api/querier.rs +++ b/zenoh/src/api/querier.rs @@ -127,13 +127,13 @@ impl<'a> Querier<'a> { &self.key_expr } - /// Get the `congestion_control` applied when routing the data. + /// Get the [`CongestionControl`] applied when routing the data. #[inline] pub fn congestion_control(&self) -> CongestionControl { self.qos.congestion_control() } - /// Get the priority of the written data. + /// Get the [`Priority`] of the querier requests. #[inline] pub fn priority(&self) -> Priority { self.qos.priority() diff --git a/zenoh/src/api/sample.rs b/zenoh/src/api/sample.rs index 3ec42a6793..7dfa709160 100644 --- a/zenoh/src/api/sample.rs +++ b/zenoh/src/api/sample.rs @@ -274,12 +274,12 @@ impl Sample { self.timestamp.as_ref() } - /// Gets the congestion control of this Sample. + /// Gets the [`CongestionControl`] applied when routing the data. pub fn congestion_control(&self) -> CongestionControl { self.qos.congestion_control() } - /// Gets the priority of this Sample. + /// Gets the [`Priority`] of this Sample. pub fn priority(&self) -> Priority { self.qos.priority() } @@ -302,13 +302,13 @@ impl Sample { self.source_info.as_ref() } - /// Gets the sample attachment: a map of key-value pairs, where each key and each value is a byte-slice. + /// Gets the optional sample attachment as bytes. #[inline] pub fn attachment(&self) -> Option<&ZBytes> { self.attachment.as_ref() } - /// Gets the sample attachment: a map of key-value pairs, where each key and each value is a byte-slice. + /// Gets a mutable reference to the optional sample attachment bytes. #[inline] pub fn attachment_mut(&mut self) -> Option<&mut ZBytes> { self.attachment.as_mut() @@ -420,18 +420,24 @@ impl From for QoS { #[zenoh_macros::internal_trait] impl QoSBuilderTrait for QoSBuilder { + /// Changes the [`CongestionControl`](crate::qos::CongestionControl) to apply when routing the data. fn congestion_control(self, congestion_control: CongestionControl) -> Self { let mut inner = self.0.inner; inner.set_congestion_control(congestion_control); Self(QoS { inner }) } + /// Changes the [`Priority`](crate::qos::Priority) to apply when routing the data. fn priority(self, priority: Priority) -> Self { let mut inner = self.0.inner; inner.set_priority(priority.into()); Self(QoS { inner }) } + /// Changes the Express policy to apply when routing the data. + /// + /// When express is set to `true`, then the message will not be batched. + /// This usually has a positive impact on latency but a negative impact on throughput. fn express(self, is_express: bool) -> Self { let mut inner = self.0.inner; inner.set_is_express(is_express); @@ -440,7 +446,7 @@ impl QoSBuilderTrait for QoSBuilder { } impl QoS { - /// Gets the priority of the message. + /// Get the [`Priority`] of the message. pub fn priority(&self) -> Priority { match Priority::try_from(self.inner.get_priority()) { Ok(p) => p, @@ -454,7 +460,7 @@ impl QoS { } } - /// Gets the congestion control of the message. + /// Get the [`CongestionControl`] applied when routing the data. pub fn congestion_control(&self) -> CongestionControl { self.inner.get_congestion_control() }