From 052a751a561e983ac5245232036f740a59f47e92 Mon Sep 17 00:00:00 2001 From: OlivierHecart Date: Wed, 18 Dec 2024 11:16:33 +0100 Subject: [PATCH] Cache full expression in Resource tree --- zenoh/src/net/routing/dispatcher/face.rs | 2 +- zenoh/src/net/routing/dispatcher/interests.rs | 2 +- zenoh/src/net/routing/dispatcher/pubsub.rs | 2 +- zenoh/src/net/routing/dispatcher/queries.rs | 2 +- zenoh/src/net/routing/dispatcher/resource.rs | 30 +++++++++++-------- zenoh/src/net/routing/dispatcher/tables.rs | 2 +- zenoh/src/net/routing/dispatcher/token.rs | 4 +-- zenoh/src/net/routing/hat/client/interests.rs | 10 +++++-- zenoh/src/net/routing/hat/client/pubsub.rs | 6 ++-- zenoh/src/net/routing/hat/client/queries.rs | 6 ++-- zenoh/src/net/routing/hat/client/token.rs | 16 +++++----- .../net/routing/hat/linkstate_peer/pubsub.rs | 22 +++++++------- .../net/routing/hat/linkstate_peer/queries.rs | 20 ++++++------- .../net/routing/hat/linkstate_peer/token.rs | 26 ++++++++-------- .../src/net/routing/hat/p2p_peer/interests.rs | 10 +++++-- zenoh/src/net/routing/hat/p2p_peer/pubsub.rs | 22 +++++++------- zenoh/src/net/routing/hat/p2p_peer/queries.rs | 16 +++++----- zenoh/src/net/routing/hat/p2p_peer/token.rs | 24 +++++++-------- zenoh/src/net/routing/hat/router/pubsub.rs | 26 ++++++++-------- zenoh/src/net/routing/hat/router/queries.rs | 26 ++++++++-------- zenoh/src/net/routing/hat/router/token.rs | 30 +++++++++---------- zenoh/src/net/routing/mod.rs | 2 +- zenoh/src/net/tests/tables.rs | 3 +- 23 files changed, 160 insertions(+), 149 deletions(-) diff --git a/zenoh/src/net/routing/dispatcher/face.rs b/zenoh/src/net/routing/dispatcher/face.rs index 6e1db6bbf1..bd781a55d1 100644 --- a/zenoh/src/net/routing/dispatcher/face.rs +++ b/zenoh/src/net/routing/dispatcher/face.rs @@ -144,7 +144,7 @@ impl FaceState { } pub(crate) fn update_interceptors_caches(&self, res: &mut Arc) { - if let Ok(expr) = KeyExpr::try_from(res.expr()) { + if let Ok(expr) = KeyExpr::try_from(res.expr_to_string()) { if let Some(interceptor) = self.in_interceptors.as_ref() { let cache = interceptor.compute_keyexpr_cache(&expr); get_mut_unchecked( diff --git a/zenoh/src/net/routing/dispatcher/interests.rs b/zenoh/src/net/routing/dispatcher/interests.rs index 5ee860da2f..82a372becc 100644 --- a/zenoh/src/net/routing/dispatcher/interests.rs +++ b/zenoh/src/net/routing/dispatcher/interests.rs @@ -217,7 +217,7 @@ pub(crate) fn declare_interest( let wtables = zwrite!(tables_ref.tables); (res.unwrap(), wtables) } else { - let mut fullexpr = prefix.expr(); + let mut fullexpr = prefix.expr_to_string(); fullexpr.push_str(expr.suffix.as_ref()); let mut matches = keyexpr::new(fullexpr.as_str()) .map(|ke| Resource::get_matches(&rtables, ke)) diff --git a/zenoh/src/net/routing/dispatcher/pubsub.rs b/zenoh/src/net/routing/dispatcher/pubsub.rs index 4c5ff66c8f..caa5e9f3a8 100644 --- a/zenoh/src/net/routing/dispatcher/pubsub.rs +++ b/zenoh/src/net/routing/dispatcher/pubsub.rs @@ -67,7 +67,7 @@ pub(crate) fn declare_subscription( let wtables = zwrite!(tables.tables); (res.unwrap(), wtables) } else { - let mut fullexpr = prefix.expr(); + let mut fullexpr = prefix.expr_to_string(); fullexpr.push_str(expr.suffix.as_ref()); let mut matches = keyexpr::new(fullexpr.as_str()) .map(|ke| Resource::get_matches(&rtables, ke)) diff --git a/zenoh/src/net/routing/dispatcher/queries.rs b/zenoh/src/net/routing/dispatcher/queries.rs index b56c887b65..de720183d2 100644 --- a/zenoh/src/net/routing/dispatcher/queries.rs +++ b/zenoh/src/net/routing/dispatcher/queries.rs @@ -95,7 +95,7 @@ pub(crate) fn declare_queryable( let wtables = zwrite!(tables.tables); (res.unwrap(), wtables) } else { - let mut fullexpr = prefix.expr(); + let mut fullexpr = prefix.expr_to_string(); fullexpr.push_str(expr.suffix.as_ref()); let mut matches = keyexpr::new(fullexpr.as_str()) .map(|ke| Resource::get_matches(&rtables, ke)) diff --git a/zenoh/src/net/routing/dispatcher/resource.rs b/zenoh/src/net/routing/dispatcher/resource.rs index 2931dfdd0f..836bb131da 100644 --- a/zenoh/src/net/routing/dispatcher/resource.rs +++ b/zenoh/src/net/routing/dispatcher/resource.rs @@ -172,6 +172,7 @@ impl ResourceContext { pub struct Resource { pub(crate) parent: Option>, + pub(crate) expr: String, pub(crate) suffix: String, pub(crate) nonwild_prefix: Option<(Arc, String)>, pub(crate) children: HashMap>, @@ -211,6 +212,7 @@ impl Resource { Resource { parent: Some(parent.clone()), + expr: parent.expr.clone() + suffix, suffix: String::from(suffix), nonwild_prefix, children: HashMap::new(), @@ -219,11 +221,12 @@ impl Resource { } } - pub fn expr(&self) -> String { - match &self.parent { - Some(parent) => parent.expr() + &self.suffix, - None => String::from(""), - } + pub fn expr_to_string(&self) -> String { + self.expr.clone() + } + + pub fn expr(&self) -> &str { + &self.expr } #[inline(always)] @@ -253,7 +256,7 @@ impl Resource { if !nonwild_prefix.expr().is_empty() { (Some(nonwild_prefix.clone()), wildsuffix.clone()) } else { - (None, res.expr()) + (None, res.expr().to_string()) } } } @@ -295,6 +298,7 @@ impl Resource { pub fn root() -> Arc { Arc::new(Resource { parent: None, + expr: String::from(""), suffix: String::from(""), nonwild_prefix: None, children: HashMap::new(), @@ -345,7 +349,7 @@ impl Resource { #[cfg(test)] pub fn print_tree(from: &Arc) -> String { - let mut result = from.expr(); + let mut result = from.expr().to_string(); result.push('\n'); for child in from.children.values() { result.push_str(&Resource::print_tree(child)); @@ -511,10 +515,10 @@ impl Resource { ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareKeyExpr(DeclareKeyExpr { id: expr_id, - wire_expr: nonwild_prefix.expr().into(), + wire_expr: nonwild_prefix.expr_to_string().into(), }), }, - nonwild_prefix.expr(), + nonwild_prefix.expr_to_string(), )); face.update_interceptors_caches(&mut nonwild_prefix); WireExpr { @@ -523,7 +527,7 @@ impl Resource { mapping: Mapping::Sender, } } else { - res.expr().into() + res.expr_to_string().into() } } None => wildsuffix.into(), @@ -701,7 +705,7 @@ pub(crate) fn register_expr( { Some(mut prefix) => match face.remote_mappings.get(&expr_id) { Some(res) => { - let mut fullexpr = prefix.expr(); + let mut fullexpr = prefix.expr_to_string(); fullexpr.push_str(expr.suffix.as_ref()); if res.expr() != fullexpr { tracing::error!( @@ -722,7 +726,7 @@ pub(crate) fn register_expr( let wtables = zwrite!(tables.tables); (res.unwrap(), wtables) } else { - let mut fullexpr = prefix.expr(); + let mut fullexpr = prefix.expr_to_string(); fullexpr.push_str(expr.suffix.as_ref()); let mut matches = keyexpr::new(fullexpr.as_str()) .map(|ke| Resource::get_matches(&rtables, ke)) @@ -786,7 +790,7 @@ pub(crate) fn register_expr_interest( let wtables = zwrite!(tables.tables); (res.unwrap(), wtables) } else { - let mut fullexpr = prefix.expr(); + let mut fullexpr = prefix.expr_to_string(); fullexpr.push_str(expr.suffix.as_ref()); let mut matches = keyexpr::new(fullexpr.as_str()) .map(|ke| Resource::get_matches(&rtables, ke)) diff --git a/zenoh/src/net/routing/dispatcher/tables.rs b/zenoh/src/net/routing/dispatcher/tables.rs index 6aac7d0a2d..981a5ed8da 100644 --- a/zenoh/src/net/routing/dispatcher/tables.rs +++ b/zenoh/src/net/routing/dispatcher/tables.rs @@ -56,7 +56,7 @@ impl<'a> RoutingExpr<'a> { #[inline] pub(crate) fn full_expr(&mut self) -> &str { if self.full.is_none() { - self.full = Some(self.prefix.expr() + self.suffix); + self.full = Some(self.prefix.expr_to_string() + self.suffix); } self.full.as_ref().unwrap() } diff --git a/zenoh/src/net/routing/dispatcher/token.rs b/zenoh/src/net/routing/dispatcher/token.rs index 397f2304f3..b7f64d39cd 100644 --- a/zenoh/src/net/routing/dispatcher/token.rs +++ b/zenoh/src/net/routing/dispatcher/token.rs @@ -63,7 +63,7 @@ pub(crate) fn declare_token( let wtables = zwrite!(tables.tables); (res.unwrap(), wtables) } else { - let mut fullexpr = prefix.expr(); + let mut fullexpr = prefix.expr_to_string(); fullexpr.push_str(expr.suffix.as_ref()); let mut matches = keyexpr::new(fullexpr.as_str()) .map(|ke| Resource::get_matches(&rtables, ke)) @@ -123,7 +123,7 @@ pub(crate) fn undeclare_token( None => { // Here we create a Resource that will immediately be removed after treatment // TODO this could be improved - let mut fullexpr = prefix.expr(); + let mut fullexpr = prefix.expr_to_string(); fullexpr.push_str(expr.wire_expr.suffix.as_ref()); let mut matches = keyexpr::new(fullexpr.as_str()) .map(|ke| Resource::get_matches(&rtables, ke)) diff --git a/zenoh/src/net/routing/hat/client/interests.rs b/zenoh/src/net/routing/hat/client/interests.rs index 0f900d5958..a859e0b1b9 100644 --- a/zenoh/src/net/routing/hat/client/interests.rs +++ b/zenoh/src/net/routing/hat/client/interests.rs @@ -66,7 +66,9 @@ pub(super) fn interests_new_face(tables: &mut Tables, face: &mut Arc) ext_tstamp: None, ext_nodeid: ext::NodeIdType::DEFAULT, }, - res.as_ref().map(|res| res.expr()).unwrap_or_default(), + res.as_ref() + .map(|res| res.expr_to_string()) + .unwrap_or_default(), )); } } @@ -146,7 +148,9 @@ impl HatInterestTrait for HatCode { ext_tstamp: None, ext_nodeid: ext::NodeIdType::DEFAULT, }, - res.as_ref().map(|res| res.expr()).unwrap_or_default(), + res.as_ref() + .map(|res| res.expr_to_string()) + .unwrap_or_default(), )); } @@ -223,7 +227,7 @@ impl HatInterestTrait for HatCode { local_interest .res .as_ref() - .map(|res| res.expr()) + .map(|res| res.expr_to_string()) .unwrap_or_default(), )); get_mut_unchecked(dst_face).local_interests.remove(&id); diff --git a/zenoh/src/net/routing/hat/client/pubsub.rs b/zenoh/src/net/routing/hat/client/pubsub.rs index cf92614e5f..689874c599 100644 --- a/zenoh/src/net/routing/hat/client/pubsub.rs +++ b/zenoh/src/net/routing/hat/client/pubsub.rs @@ -71,7 +71,7 @@ fn propagate_simple_subscription_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -176,7 +176,7 @@ fn propagate_forget_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -214,7 +214,7 @@ pub(super) fn undeclare_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/client/queries.rs b/zenoh/src/net/routing/hat/client/queries.rs index 7f2f9cb8d9..67084e5166 100644 --- a/zenoh/src/net/routing/hat/client/queries.rs +++ b/zenoh/src/net/routing/hat/client/queries.rs @@ -121,7 +121,7 @@ fn propagate_simple_queryable( ext_info: info, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -194,7 +194,7 @@ fn propagate_forget_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -238,7 +238,7 @@ pub(super) fn undeclare_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/client/token.rs b/zenoh/src/net/routing/hat/client/token.rs index 098515c03f..107eef3d06 100644 --- a/zenoh/src/net/routing/hat/client/token.rs +++ b/zenoh/src/net/routing/hat/client/token.rs @@ -59,7 +59,7 @@ fn propagate_simple_token_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -133,7 +133,7 @@ fn declare_simple_token( ext_nodeid: ext::NodeIdType::default(), body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - res.expr(), + res.expr_to_string(), ), ); return; @@ -185,7 +185,7 @@ fn propagate_forget_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } else if face_hat!(face) @@ -210,7 +210,7 @@ fn propagate_forget_simple_token( }, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -253,7 +253,7 @@ pub(super) fn undeclare_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -343,7 +343,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -372,7 +372,7 @@ pub(crate) fn declare_token_interest( wire_expr, }), }, - res.expr(), + res.expr_to_string(), ), ) } @@ -400,7 +400,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - token.expr(), + token.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs b/zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs index fc2074c0b9..0e96eef1c7 100644 --- a/zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs +++ b/zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs @@ -83,7 +83,7 @@ fn send_sourced_subscription_to_net_children( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -123,7 +123,7 @@ fn propagate_simple_subscription_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } else { @@ -163,7 +163,7 @@ fn propagate_simple_subscription_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -371,7 +371,7 @@ fn send_forget_sourced_subscription_to_net_children( ext_wire_expr: WireExprType { wire_expr }, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -401,7 +401,7 @@ fn propagate_forget_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -431,7 +431,7 @@ fn propagate_forget_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -557,7 +557,7 @@ pub(super) fn undeclare_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -590,7 +590,7 @@ pub(super) fn undeclare_simple_subscription( }, ), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -724,7 +724,7 @@ pub(super) fn declare_sub_interest( wire_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -750,7 +750,7 @@ pub(super) fn declare_sub_interest( wire_expr, }), }, - sub.expr(), + sub.expr_to_string(), ), ); } @@ -776,7 +776,7 @@ pub(super) fn declare_sub_interest( wire_expr, }), }, - sub.expr(), + sub.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/linkstate_peer/queries.rs b/zenoh/src/net/routing/hat/linkstate_peer/queries.rs index 2f7772193a..5ee36d676a 100644 --- a/zenoh/src/net/routing/hat/linkstate_peer/queries.rs +++ b/zenoh/src/net/routing/hat/linkstate_peer/queries.rs @@ -156,7 +156,7 @@ fn send_sourced_queryable_to_net_children( ext_info: *qabl_info, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -209,7 +209,7 @@ fn propagate_simple_queryable( ext_info: info, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -388,7 +388,7 @@ fn send_forget_sourced_queryable_to_net_children( ext_wire_expr: WireExprType { wire_expr }, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -418,7 +418,7 @@ fn propagate_forget_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -449,7 +449,7 @@ fn propagate_forget_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -581,7 +581,7 @@ pub(super) fn undeclare_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -612,7 +612,7 @@ pub(super) fn undeclare_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -798,7 +798,7 @@ pub(super) fn declare_qabl_interest( ext_info: info, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -827,7 +827,7 @@ pub(super) fn declare_qabl_interest( ext_info: info, }), }, - qabl.expr(), + qabl.expr_to_string(), ), ); } @@ -855,7 +855,7 @@ pub(super) fn declare_qabl_interest( ext_info: info, }), }, - qabl.expr(), + qabl.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/linkstate_peer/token.rs b/zenoh/src/net/routing/hat/linkstate_peer/token.rs index e016b70de1..f60daf9b67 100644 --- a/zenoh/src/net/routing/hat/linkstate_peer/token.rs +++ b/zenoh/src/net/routing/hat/linkstate_peer/token.rs @@ -70,7 +70,7 @@ fn send_sourced_token_to_net_clildren( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -109,7 +109,7 @@ fn propagate_simple_token_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } else { @@ -149,7 +149,7 @@ fn propagate_simple_token_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -343,7 +343,7 @@ fn send_forget_sourced_token_to_net_clildren( ext_wire_expr: WireExprType { wire_expr }, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -373,7 +373,7 @@ fn propagate_forget_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -404,7 +404,7 @@ fn propagate_forget_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -434,7 +434,7 @@ fn propagate_forget_sourced_token( } else { tracing::trace!( "Propagating forget token {}: tree for node {} sid:{} not yet ready", - res.expr(), + res.expr_to_string(), tree_sid.index(), source ); @@ -442,7 +442,7 @@ fn propagate_forget_sourced_token( } None => tracing::error!( "Error propagating forget token {}: cannot get index of {}!", - res.expr(), + res.expr_to_string(), source ), } @@ -528,7 +528,7 @@ pub(super) fn undeclare_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -559,7 +559,7 @@ pub(super) fn undeclare_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -684,7 +684,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -708,7 +708,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - token.expr(), + token.expr_to_string(), ), ); } @@ -733,7 +733,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - token.expr(), + token.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/p2p_peer/interests.rs b/zenoh/src/net/routing/hat/p2p_peer/interests.rs index abe1108f78..3f0d556707 100644 --- a/zenoh/src/net/routing/hat/p2p_peer/interests.rs +++ b/zenoh/src/net/routing/hat/p2p_peer/interests.rs @@ -73,7 +73,9 @@ pub(super) fn interests_new_face(tables: &mut Tables, face: &mut Arc) ext_tstamp: None, ext_nodeid: ext::NodeIdType::DEFAULT, }, - res.as_ref().map(|res| res.expr()).unwrap_or_default(), + res.as_ref() + .map(|res| res.expr_to_string()) + .unwrap_or_default(), )); } } @@ -184,7 +186,9 @@ impl HatInterestTrait for HatCode { ext_tstamp: None, ext_nodeid: ext::NodeIdType::DEFAULT, }, - res.as_ref().map(|res| res.expr()).unwrap_or_default(), + res.as_ref() + .map(|res| res.expr_to_string()) + .unwrap_or_default(), )); } } @@ -249,7 +253,7 @@ impl HatInterestTrait for HatCode { local_interest .res .as_ref() - .map(|res| res.expr()) + .map(|res| res.expr_to_string()) .unwrap_or_default(), )); get_mut_unchecked(dst_face).local_interests.remove(&id); diff --git a/zenoh/src/net/routing/hat/p2p_peer/pubsub.rs b/zenoh/src/net/routing/hat/p2p_peer/pubsub.rs index 8a050d5c03..077ac36c32 100644 --- a/zenoh/src/net/routing/hat/p2p_peer/pubsub.rs +++ b/zenoh/src/net/routing/hat/p2p_peer/pubsub.rs @@ -78,7 +78,7 @@ fn propagate_simple_subscription_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } else { @@ -118,7 +118,7 @@ fn propagate_simple_subscription_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -206,10 +206,10 @@ fn declare_simple_subscription( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareSubscriber(DeclareSubscriber { id: 0, // @TODO use proper SubscriberId - wire_expr: res.expr().into(), + wire_expr: res.expr_to_string().into(), }), }, - res.expr(), + res.expr_to_string(), )) } } @@ -257,7 +257,7 @@ fn propagate_forget_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -285,7 +285,7 @@ fn propagate_forget_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -326,7 +326,7 @@ pub(super) fn undeclare_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -354,7 +354,7 @@ pub(super) fn undeclare_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -459,7 +459,7 @@ pub(super) fn declare_sub_interest( wire_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -488,7 +488,7 @@ pub(super) fn declare_sub_interest( DeclareSubscriber { id, wire_expr }, ), }, - sub.expr(), + sub.expr_to_string(), ), ); } @@ -521,7 +521,7 @@ pub(super) fn declare_sub_interest( wire_expr, }), }, - sub.expr(), + sub.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/p2p_peer/queries.rs b/zenoh/src/net/routing/hat/p2p_peer/queries.rs index db67952745..baf51a064b 100644 --- a/zenoh/src/net/routing/hat/p2p_peer/queries.rs +++ b/zenoh/src/net/routing/hat/p2p_peer/queries.rs @@ -131,7 +131,7 @@ fn propagate_simple_queryable_to( ext_info: info, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -226,7 +226,7 @@ fn propagate_forget_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -254,7 +254,7 @@ fn propagate_forget_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -300,7 +300,7 @@ pub(super) fn undeclare_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -328,7 +328,7 @@ pub(super) fn undeclare_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -444,7 +444,7 @@ pub(super) fn declare_qabl_interest( ext_info: info, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -476,7 +476,7 @@ pub(super) fn declare_qabl_interest( ext_info: info, }), }, - qabl.expr(), + qabl.expr_to_string(), ), ); } @@ -512,7 +512,7 @@ pub(super) fn declare_qabl_interest( ext_info: info, }), }, - qabl.expr(), + qabl.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/p2p_peer/token.rs b/zenoh/src/net/routing/hat/p2p_peer/token.rs index 490cd5b5a0..dd9950433d 100644 --- a/zenoh/src/net/routing/hat/p2p_peer/token.rs +++ b/zenoh/src/net/routing/hat/p2p_peer/token.rs @@ -79,7 +79,7 @@ fn propagate_simple_token_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } else { @@ -123,7 +123,7 @@ fn propagate_simple_token_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -209,7 +209,7 @@ fn declare_simple_token( ext_nodeid: ext::NodeIdType::default(), body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - res.expr(), + res.expr_to_string(), ), ); return; @@ -269,7 +269,7 @@ fn propagate_forget_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } else if src_face.id != face.id @@ -295,7 +295,7 @@ fn propagate_forget_simple_token( }, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -323,7 +323,7 @@ fn propagate_forget_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } else if face_hat!(face) @@ -348,7 +348,7 @@ fn propagate_forget_simple_token( }, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -394,7 +394,7 @@ pub(super) fn undeclare_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -423,7 +423,7 @@ pub(super) fn undeclare_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -525,7 +525,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -555,7 +555,7 @@ pub(crate) fn declare_token_interest( wire_expr, }), }, - token.expr(), + token.expr_to_string(), ), ); } @@ -584,7 +584,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - token.expr(), + token.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/router/pubsub.rs b/zenoh/src/net/routing/hat/router/pubsub.rs index a1fb8de164..60b7e8d135 100644 --- a/zenoh/src/net/routing/hat/router/pubsub.rs +++ b/zenoh/src/net/routing/hat/router/pubsub.rs @@ -84,7 +84,7 @@ fn send_sourced_subscription_to_net_children( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -151,7 +151,7 @@ fn propagate_simple_subscription_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -407,7 +407,7 @@ fn send_forget_sourced_subscription_to_net_children( ext_wire_expr: WireExprType { wire_expr }, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -437,7 +437,7 @@ fn propagate_forget_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -469,7 +469,7 @@ fn propagate_forget_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -517,7 +517,7 @@ fn propagate_forget_simple_subscription_to_peers( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -683,7 +683,7 @@ pub(super) fn undeclare_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -715,7 +715,7 @@ pub(super) fn undeclare_simple_subscription( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -883,7 +883,7 @@ pub(super) fn pubsub_linkstate_change( ext_wire_expr: WireExprType { wire_expr }, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -914,7 +914,7 @@ pub(super) fn pubsub_linkstate_change( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -976,7 +976,7 @@ pub(crate) fn declare_sub_interest( wire_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -1015,7 +1015,7 @@ pub(crate) fn declare_sub_interest( wire_expr, }), }, - sub.expr(), + sub.expr_to_string(), ), ); } @@ -1052,7 +1052,7 @@ pub(crate) fn declare_sub_interest( wire_expr, }), }, - sub.expr(), + sub.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/router/queries.rs b/zenoh/src/net/routing/hat/router/queries.rs index 6739f22bb9..d6227e441f 100644 --- a/zenoh/src/net/routing/hat/router/queries.rs +++ b/zenoh/src/net/routing/hat/router/queries.rs @@ -225,7 +225,7 @@ fn send_sourced_queryable_to_net_children( ext_info: *qabl_info, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -291,7 +291,7 @@ fn propagate_simple_queryable( ext_info: info, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -535,7 +535,7 @@ fn send_forget_sourced_queryable_to_net_children( ext_wire_expr: WireExprType { wire_expr }, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -565,7 +565,7 @@ fn propagate_forget_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -597,7 +597,7 @@ fn propagate_forget_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -645,7 +645,7 @@ fn propagate_forget_simple_queryable_to_peers( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -824,7 +824,7 @@ pub(super) fn undeclare_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -856,7 +856,7 @@ pub(super) fn undeclare_simple_queryable( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -987,7 +987,7 @@ pub(super) fn queries_linkstate_change( ext_wire_expr: WireExprType { wire_expr }, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -1020,7 +1020,7 @@ pub(super) fn queries_linkstate_change( ext_info: info, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -1195,7 +1195,7 @@ pub(crate) fn declare_qabl_interest( ext_info: info, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -1233,7 +1233,7 @@ pub(crate) fn declare_qabl_interest( ext_info: info, }), }, - qabl.expr(), + qabl.expr_to_string(), ), ); } @@ -1264,7 +1264,7 @@ pub(crate) fn declare_qabl_interest( ext_info: info, }), }, - qabl.expr(), + qabl.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/hat/router/token.rs b/zenoh/src/net/routing/hat/router/token.rs index ef60133d19..372e153348 100644 --- a/zenoh/src/net/routing/hat/router/token.rs +++ b/zenoh/src/net/routing/hat/router/token.rs @@ -71,7 +71,7 @@ fn send_sourced_token_to_net_clildren( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -137,7 +137,7 @@ fn propagate_simple_token_to( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -382,7 +382,7 @@ fn send_forget_sourced_token_to_net_clildren( ext_wire_expr: WireExprType { wire_expr }, }), }, - res.expr(), + res.expr_to_string(), )); } } @@ -413,7 +413,7 @@ fn propagate_forget_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); // NOTE(fuzzypixelz): We need to check that `face` is not the source Face of the token @@ -447,7 +447,7 @@ fn propagate_forget_simple_token( }, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -479,7 +479,7 @@ fn propagate_forget_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } else if face_hat!(face) @@ -509,7 +509,7 @@ fn propagate_forget_simple_token( }, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -557,7 +557,7 @@ fn propagate_forget_simple_token_to_peers( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -735,7 +735,7 @@ pub(super) fn undeclare_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -767,7 +767,7 @@ pub(super) fn undeclare_simple_token( ext_wire_expr: WireExprType::null(), }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -927,7 +927,7 @@ pub(super) fn token_linkstate_change( ext_wire_expr: WireExprType { wire_expr }, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -958,7 +958,7 @@ pub(super) fn token_linkstate_change( wire_expr: key_expr, }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -1020,7 +1020,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - res.expr(), + res.expr_to_string(), ), ); } @@ -1059,7 +1059,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - token.expr(), + token.expr_to_string(), ), ); } @@ -1096,7 +1096,7 @@ pub(crate) fn declare_token_interest( ext_nodeid: ext::NodeIdType::DEFAULT, body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }), }, - token.expr(), + token.expr_to_string(), ), ); } diff --git a/zenoh/src/net/routing/mod.rs b/zenoh/src/net/routing/mod.rs index cc1778b9ba..dfc02d3de6 100644 --- a/zenoh/src/net/routing/mod.rs +++ b/zenoh/src/net/routing/mod.rs @@ -163,7 +163,7 @@ impl RoutingContext { if let Some(prefix) = self.prefix() { let _ = self .full_expr - .set(prefix.expr() + self.wire_expr().unwrap().suffix.as_ref()); + .set(prefix.expr_to_string() + self.wire_expr().unwrap().suffix.as_ref()); return Some(self.full_expr.get().as_ref().unwrap()); } None diff --git a/zenoh/src/net/tests/tables.rs b/zenoh/src/net/tests/tables.rs index 8953397b8d..379ae7f983 100644 --- a/zenoh/src/net/tests/tables.rs +++ b/zenoh/src/net/tests/tables.rs @@ -162,8 +162,7 @@ fn match_test() { for key_expr2 in key_exprs.iter() { if res_matches .iter() - .map(|m| m.upgrade().unwrap().expr()) - .any(|x| x.as_str() == key_expr2.as_str()) + .any(|m| m.upgrade().unwrap().expr() == key_expr2.as_str()) { assert!(dbg!(dbg!(key_expr1).intersects(dbg!(key_expr2)))); } else {