Skip to content

Commit

Permalink
more tags
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Feb 6, 2024
1 parent a5eb563 commit efb4a45
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 101 deletions.
7 changes: 4 additions & 3 deletions commons/zenoh-protocol/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct Property {
}

/// The kind of a `Sample`.
// tags{sample.kind}
// tags{publisher.write.kind}
#[repr(u8)]
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
pub enum SampleKind {
Expand Down Expand Up @@ -93,6 +93,7 @@ impl TryFrom<u64> for SampleKind {
}

/// The global unique id of a zenoh peer.
// tags{zenoh_id}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct ZenohId(uhlc::ID);
Expand Down Expand Up @@ -347,7 +348,7 @@ impl TryFrom<u8> for Priority {
}

/// The reliability request of a subscriber.
// tags{options.reliability}
// tags{enum.reliability}
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum Reliability {
Expand Down Expand Up @@ -425,7 +426,7 @@ pub enum ConsolidationMode {
}

/// The `zenoh::queryable::Queryable`s that should be target of a `zenoh::Session::get()`.
// tags{session.query.target}
// tags{enum.query.target}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum QueryTarget {
#[default]
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl SessionInfo<'_> {
/// let zid = session.info().zid().res().await;
/// # })
/// ```
// tags{session.zid}
// tags{session.zid.get}
pub fn zid(&self) -> ZidBuilder<'_> {
ZidBuilder {
session: self.session.clone(),
Expand All @@ -202,7 +202,7 @@ impl SessionInfo<'_> {
/// while let Some(router_zid) = routers_zid.next() {}
/// # })
/// ```
// tags{session.info.routers_zid}
// tags{session.routers.get}
pub fn routers_zid(&self) -> RoutersZidBuilder<'_> {
RoutersZidBuilder {
session: self.session.clone(),
Expand All @@ -221,7 +221,7 @@ impl SessionInfo<'_> {
/// while let Some(peer_zid) = peers_zid.next() {}
/// # })
/// ```
// tags{session.info.peers_zid}
// tags{session.peers.get}
pub fn peers_zid(&self) -> PeersZidBuilder<'_> {
PeersZidBuilder {
session: self.session.clone(),
Expand Down
12 changes: 6 additions & 6 deletions zenoh/src/key_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl KeyExpr<'static> {
/// # Safety
/// Key Expressions must follow some rules to be accepted by a Zenoh network.
/// Messages addressed with invalid key expressions will be dropped.
// tags{keyexpr.from_unchecked}
// tags{keyexpr.create.from_string_unchecked}
pub unsafe fn from_string_unchecked(s: String) -> Self {
Self(KeyExprInner::Owned(OwnedKeyExpr::from_string_unchecked(s)))
}
Expand All @@ -86,7 +86,7 @@ impl KeyExpr<'static> {
/// # Safety
/// Key Expressions must follow some rules to be accepted by a Zenoh network.
/// Messages addressed with invalid key expressions will be dropped.
// tags{keyexpr.from_unchecked}
// tags{keyexpr.create.from_string_unchecked}
pub unsafe fn from_boxed_string_unchecked(s: Box<str>) -> Self {
Self(KeyExprInner::Owned(
OwnedKeyExpr::from_boxed_string_unchecked(s),
Expand All @@ -100,7 +100,7 @@ impl<'a> KeyExpr<'a> {
/// Note that to be considered a valid key expression, a string MUST be canon.
///
/// [`KeyExpr::autocanonize`] is an alternative constructor that will canonize the passed expression before constructing it.
// tags{keyexpr.new}
// tags{keyexpr.create}
pub fn new<T, E>(t: T) -> Result<Self, E>
where
Self: TryFrom<T, Error = E>,
Expand Down Expand Up @@ -163,7 +163,7 @@ impl<'a> KeyExpr<'a> {
/// # Safety
/// Key Expressions must follow some rules to be accepted by a Zenoh network.
/// Messages addressed with invalid key expressions will be dropped.
// tags{keyexpr.from_unchecked}
// tags{keyexpr.create.from_string_unchecked}
pub unsafe fn from_str_unchecked(s: &'a str) -> Self {
keyexpr::from_str_unchecked(s).into()
}
Expand Down Expand Up @@ -285,15 +285,15 @@ impl<'a> KeyExpr<'a> {
}
}

// tags{keyexpr.with_parameters}
// tags{selector.create.from_keyexpr}
pub fn with_parameters(self, selector: &'a str) -> Selector<'a> {
Selector {
key_expr: self,
parameters: selector.into(),
}
}

// tags{keyexpr.with_parameters}
// tags{selector.create.from_keyexpr}
pub fn with_owned_parameters(self, selector: String) -> Selector<'a> {
Selector {
key_expr: self,
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub mod time {
/// Generates a reception [`Timestamp`] with id=0x01.
/// This operation should be called if a timestamp is required for an incoming [`zenoh::Sample`](crate::Sample)
/// that doesn't contain any timestamp.
// tags{time.new_reception_timestamp}
// tags{timestamp.create}
pub fn new_reception_timestamp() -> Timestamp {
use std::time::{SystemTime, UNIX_EPOCH};

Expand All @@ -178,7 +178,7 @@ pub mod properties {
/// Convert a set of [`Properties`] into a [`Value`].
/// For instance, Properties: `[("k1", "v1"), ("k2, v2")]`
/// is converted into Json: `{ "k1": "v1", "k2": "v2" }`
// tags{properties.properties_to_json_value}
// tags{value.create.from_properties}
pub fn properties_to_json_value(props: &Properties) -> Value {
let json_map = props
.iter()
Expand Down Expand Up @@ -261,7 +261,7 @@ where
/// let session = zenoh::open(config).res().await.unwrap();
/// # })
/// ```
// tags{session.open}
// tags{session.create}
pub fn open<TryIntoConfig>(config: TryIntoConfig) -> OpenBuilder<TryIntoConfig>
where
TryIntoConfig: std::convert::TryInto<crate::config::Config> + Send + 'static,
Expand Down
14 changes: 7 additions & 7 deletions zenoh/src/liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<'a> Liveliness<'a> {
/// # })
/// ```
#[zenoh_macros::unstable]
// tags{liveliness.declare_token}
// tags{liveliness.token.create}
pub fn declare_token<'b, TryIntoKeyExpr>(
&self,
key_expr: TryIntoKeyExpr,
Expand Down Expand Up @@ -141,7 +141,7 @@ impl<'a> Liveliness<'a> {
/// }
/// # })
/// ```
// tags{liveliness.declare_subscriber}
// tags{liveliness.subscriber.create}
#[zenoh_macros::unstable]
pub fn declare_subscriber<'b, TryIntoKeyExpr>(
&self,
Expand Down Expand Up @@ -178,7 +178,7 @@ impl<'a> Liveliness<'a> {
/// }
/// # })
/// ```
// tags{liveliness.get}
// tags{liveliness.query_token}
#[zenoh_macros::unstable]
pub fn get<'b: 'a, TryIntoKeyExpr>(
&'a self,
Expand Down Expand Up @@ -640,7 +640,7 @@ impl<'a, 'b> LivelinessGetBuilder<'a, 'b, DefaultHandler> {
/// .unwrap();
/// # })
/// ```
// tags{liveiness.get.callback}
// tags{liveliness.query_token.callback}
#[inline]
pub fn callback<Callback>(self, callback: Callback) -> LivelinessGetBuilder<'a, 'b, Callback>
where
Expand Down Expand Up @@ -681,7 +681,7 @@ impl<'a, 'b> LivelinessGetBuilder<'a, 'b, DefaultHandler> {
/// .unwrap();
/// # })
/// ```
// tags{liveiness.get.callback}
// tags{liveliness.query_token.callback}
#[inline]
pub fn callback_mut<CallbackMut>(
self,
Expand Down Expand Up @@ -713,7 +713,7 @@ impl<'a, 'b> LivelinessGetBuilder<'a, 'b, DefaultHandler> {
/// }
/// # })
/// ```
// tags{liveiness.get.pipe}
// tags{liveliness.query_token.pipe}
#[inline]
pub fn with<Handler>(self, handler: Handler) -> LivelinessGetBuilder<'a, 'b, Handler>
where
Expand All @@ -736,7 +736,7 @@ impl<'a, 'b> LivelinessGetBuilder<'a, 'b, DefaultHandler> {

impl<'a, 'b, Handler> LivelinessGetBuilder<'a, 'b, Handler> {
/// Set query timeout.
// tags{liveiness.get.timeout}
// tags{liveliness.query_token.timeout}
#[inline]
pub fn timeout(mut self, timeout: Duration) -> Self {
self.timeout = timeout;
Expand Down
Loading

0 comments on commit efb4a45

Please sign in to comment.