From 248ba2b81ebad03e86022276e97a6f32b385ad1f Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 11 Jun 2024 18:10:55 +0200 Subject: [PATCH] renamed Inner to Proto --- commons/zenoh-codec/src/core/timestamp.rs | 4 +- commons/zenoh-codec/src/core/zenohid.rs | 36 +++++----- commons/zenoh-codec/src/network/mod.rs | 4 +- commons/zenoh-codec/src/scouting/hello.rs | 22 +++--- commons/zenoh-codec/src/scouting/scout.rs | 4 +- commons/zenoh-codec/src/transport/init.rs | 6 +- commons/zenoh-codec/src/transport/join.rs | 4 +- commons/zenoh-codec/src/zenoh/mod.rs | 6 +- commons/zenoh-codec/tests/codec.rs | 6 +- commons/zenoh-config/src/mode_dependent.rs | 2 +- commons/zenoh-protocol/src/core/mod.rs | 70 +++++++++---------- commons/zenoh-protocol/src/network/mod.rs | 8 +-- commons/zenoh-protocol/src/scouting/hello.rs | 18 ++--- commons/zenoh-protocol/src/scouting/mod.rs | 10 +-- commons/zenoh-protocol/src/scouting/scout.rs | 6 +- commons/zenoh-protocol/src/transport/init.rs | 10 +-- commons/zenoh-protocol/src/transport/join.rs | 6 +- commons/zenoh-protocol/src/zenoh/del.rs | 4 +- commons/zenoh-protocol/src/zenoh/mod.rs | 6 +- commons/zenoh-protocol/src/zenoh/put.rs | 4 +- io/zenoh-transport/src/lib.rs | 4 +- io/zenoh-transport/src/manager.rs | 16 ++--- io/zenoh-transport/src/multicast/link.rs | 4 +- io/zenoh-transport/src/multicast/manager.rs | 4 +- io/zenoh-transport/src/multicast/transport.rs | 4 +- .../src/unicast/establishment/accept.rs | 14 ++-- .../src/unicast/establishment/cookie.rs | 8 +-- .../src/unicast/establishment/mod.rs | 6 +- .../src/unicast/establishment/open.rs | 10 +-- .../src/unicast/lowlatency/transport.rs | 4 +- io/zenoh-transport/src/unicast/manager.rs | 10 +-- io/zenoh-transport/src/unicast/mod.rs | 6 +- .../src/unicast/transport_unicast_inner.rs | 4 +- .../src/unicast/universal/transport.rs | 4 +- io/zenoh-transport/tests/endpoints.rs | 4 +- .../tests/multicast_compression.rs | 6 +- .../tests/multicast_transport.rs | 6 +- .../tests/transport_whitelist.rs | 4 +- .../tests/unicast_authenticator.rs | 16 ++--- .../tests/unicast_compression.rs | 6 +- .../tests/unicast_concurrent.rs | 6 +- .../tests/unicast_defragmentation.rs | 6 +- .../tests/unicast_intermittent.rs | 10 +-- io/zenoh-transport/tests/unicast_multilink.rs | 8 +-- io/zenoh-transport/tests/unicast_openclose.rs | 8 +-- .../tests/unicast_priorities.rs | 6 +- io/zenoh-transport/tests/unicast_shm.rs | 8 +-- .../tests/unicast_simultaneous.rs | 10 +-- io/zenoh-transport/tests/unicast_time.rs | 6 +- io/zenoh-transport/tests/unicast_transport.rs | 6 +- zenoh/src/api/publisher.rs | 4 +- zenoh/src/api/query.rs | 6 +- zenoh/src/api/queryable.rs | 10 +-- zenoh/src/api/sample.rs | 12 ++-- zenoh/src/api/session.rs | 4 +- zenoh/src/api/subscriber.rs | 6 +- zenoh/src/net/codec/linkstate.rs | 4 +- zenoh/src/net/protocol/linkstate.rs | 6 +- zenoh/src/net/routing/dispatcher/face.rs | 6 +- zenoh/src/net/routing/dispatcher/tables.rs | 8 +-- .../src/net/routing/hat/linkstate_peer/mod.rs | 10 +-- .../net/routing/hat/linkstate_peer/network.rs | 34 ++++----- .../net/routing/hat/linkstate_peer/pubsub.rs | 22 +++--- .../net/routing/hat/linkstate_peer/queries.rs | 20 +++--- zenoh/src/net/routing/hat/mod.rs | 8 +-- zenoh/src/net/routing/hat/p2p_peer/gossip.rs | 26 +++---- zenoh/src/net/routing/hat/router/mod.rs | 30 ++++---- zenoh/src/net/routing/hat/router/network.rs | 40 +++++------ zenoh/src/net/routing/hat/router/pubsub.rs | 36 +++++----- zenoh/src/net/routing/hat/router/queries.rs | 34 ++++----- .../net/routing/interceptor/access_control.rs | 12 ++-- zenoh/src/net/routing/router.rs | 6 +- zenoh/src/net/runtime/orchestrator.rs | 22 +++--- zenoh/src/net/tests/tables.rs | 12 ++-- 74 files changed, 414 insertions(+), 414 deletions(-) diff --git a/commons/zenoh-codec/src/core/timestamp.rs b/commons/zenoh-codec/src/core/timestamp.rs index 4e6788bb7a..3ec059ae1b 100644 --- a/commons/zenoh-codec/src/core/timestamp.rs +++ b/commons/zenoh-codec/src/core/timestamp.rs @@ -17,7 +17,7 @@ use zenoh_buffers::{ reader::{DidntRead, Reader}, writer::{DidntWrite, Writer}, }; -use zenoh_protocol::core::{Timestamp, ZenohIdInner}; +use zenoh_protocol::core::{Timestamp, ZenohIdProto}; use crate::{LCodec, RCodec, WCodec, Zenoh080}; @@ -53,7 +53,7 @@ where if size > (uhlc::ID::MAX_SIZE) { return Err(DidntRead); } - let mut id = [0_u8; ZenohIdInner::MAX_SIZE]; + let mut id = [0_u8; ZenohIdProto::MAX_SIZE]; reader.read_exact(&mut id[..size])?; let time = uhlc::NTP64(time); diff --git a/commons/zenoh-codec/src/core/zenohid.rs b/commons/zenoh-codec/src/core/zenohid.rs index 26bf56e948..4ea06f4887 100644 --- a/commons/zenoh-codec/src/core/zenohid.rs +++ b/commons/zenoh-codec/src/core/zenohid.rs @@ -17,70 +17,70 @@ use zenoh_buffers::{ reader::{DidntRead, Reader}, writer::{DidntWrite, Writer}, }; -use zenoh_protocol::core::ZenohIdInner; +use zenoh_protocol::core::ZenohIdProto; use crate::{LCodec, RCodec, WCodec, Zenoh080, Zenoh080Length}; -impl LCodec<&ZenohIdInner> for Zenoh080 { - fn w_len(self, x: &ZenohIdInner) -> usize { +impl LCodec<&ZenohIdProto> for Zenoh080 { + fn w_len(self, x: &ZenohIdProto) -> usize { x.size() } } -impl WCodec<&ZenohIdInner, &mut W> for Zenoh080 +impl WCodec<&ZenohIdProto, &mut W> for Zenoh080 where W: Writer, { type Output = Result<(), DidntWrite>; - fn write(self, writer: &mut W, x: &ZenohIdInner) -> Self::Output { + fn write(self, writer: &mut W, x: &ZenohIdProto) -> Self::Output { self.write(&mut *writer, &x.to_le_bytes()[..x.size()]) } } -impl RCodec for Zenoh080 +impl RCodec for Zenoh080 where R: Reader, { type Error = DidntRead; - fn read(self, reader: &mut R) -> Result { + fn read(self, reader: &mut R) -> Result { let size: usize = self.read(&mut *reader)?; - if size > ZenohIdInner::MAX_SIZE { + if size > ZenohIdProto::MAX_SIZE { return Err(DidntRead); } - let mut id = [0; ZenohIdInner::MAX_SIZE]; + let mut id = [0; ZenohIdProto::MAX_SIZE]; reader.read_exact(&mut id[..size])?; - ZenohIdInner::try_from(&id[..size]).map_err(|_| DidntRead) + ZenohIdProto::try_from(&id[..size]).map_err(|_| DidntRead) } } -impl WCodec<&ZenohIdInner, &mut W> for Zenoh080Length +impl WCodec<&ZenohIdProto, &mut W> for Zenoh080Length where W: Writer, { type Output = Result<(), DidntWrite>; - fn write(self, writer: &mut W, x: &ZenohIdInner) -> Self::Output { - if self.length > ZenohIdInner::MAX_SIZE { + fn write(self, writer: &mut W, x: &ZenohIdProto) -> Self::Output { + if self.length > ZenohIdProto::MAX_SIZE { return Err(DidntWrite); } writer.write_exact(&x.to_le_bytes()[..x.size()]) } } -impl RCodec for Zenoh080Length +impl RCodec for Zenoh080Length where R: Reader, { type Error = DidntRead; - fn read(self, reader: &mut R) -> Result { - if self.length > ZenohIdInner::MAX_SIZE { + fn read(self, reader: &mut R) -> Result { + if self.length > ZenohIdProto::MAX_SIZE { return Err(DidntRead); } - let mut id = [0; ZenohIdInner::MAX_SIZE]; + let mut id = [0; ZenohIdProto::MAX_SIZE]; reader.read_exact(&mut id[..self.length])?; - ZenohIdInner::try_from(&id[..self.length]).map_err(|_| DidntRead) + ZenohIdProto::try_from(&id[..self.length]).map_err(|_| DidntRead) } } diff --git a/commons/zenoh-codec/src/network/mod.rs b/commons/zenoh-codec/src/network/mod.rs index d3475af195..c68a3470aa 100644 --- a/commons/zenoh-codec/src/network/mod.rs +++ b/commons/zenoh-codec/src/network/mod.rs @@ -24,7 +24,7 @@ use zenoh_buffers::{ }; use zenoh_protocol::{ common::{imsg, ZExtZ64, ZExtZBufHeader}, - core::{EntityId, Reliability, ZenohIdInner}, + core::{EntityId, Reliability, ZenohIdProto}, network::{ext::EntityGlobalIdType, *}, }; @@ -265,7 +265,7 @@ where let length = 1 + ((flags >> 4) as usize); let lodec = Zenoh080Length::new(length); - let zid: ZenohIdInner = lodec.read(&mut *reader)?; + let zid: ZenohIdProto = lodec.read(&mut *reader)?; let eid: EntityId = self.codec.read(&mut *reader)?; diff --git a/commons/zenoh-codec/src/scouting/hello.rs b/commons/zenoh-codec/src/scouting/hello.rs index ed15938a62..770519855b 100644 --- a/commons/zenoh-codec/src/scouting/hello.rs +++ b/commons/zenoh-codec/src/scouting/hello.rs @@ -19,23 +19,23 @@ use zenoh_buffers::{ }; use zenoh_protocol::{ common::{imsg, ZExtUnknown}, - core::{Locator, WhatAmI, ZenohIdInner}, + core::{Locator, WhatAmI, ZenohIdProto}, scouting::{ - hello::{flag, HelloInner}, + hello::{flag, HelloProto}, id, }, }; use crate::{RCodec, WCodec, Zenoh080, Zenoh080Header, Zenoh080Length}; -impl WCodec<&HelloInner, &mut W> for Zenoh080 +impl WCodec<&HelloProto, &mut W> for Zenoh080 where W: Writer, { type Output = Result<(), DidntWrite>; - fn write(self, writer: &mut W, x: &HelloInner) -> Self::Output { - let HelloInner { + fn write(self, writer: &mut W, x: &HelloProto) -> Self::Output { + let HelloProto { version, whatami, zid, @@ -73,26 +73,26 @@ where } } -impl RCodec for Zenoh080 +impl RCodec for Zenoh080 where R: Reader, { type Error = DidntRead; - fn read(self, reader: &mut R) -> Result { + fn read(self, reader: &mut R) -> Result { let header: u8 = self.read(&mut *reader)?; let codec = Zenoh080Header::new(header); codec.read(reader) } } -impl RCodec for Zenoh080Header +impl RCodec for Zenoh080Header where R: Reader, { type Error = DidntRead; - fn read(self, reader: &mut R) -> Result { + fn read(self, reader: &mut R) -> Result { if imsg::mid(self.header) != id::HELLO { return Err(DidntRead); } @@ -108,7 +108,7 @@ where }; let length = 1 + ((flags >> 4) as usize); let lodec = Zenoh080Length::new(length); - let zid: ZenohIdInner = lodec.read(&mut *reader)?; + let zid: ZenohIdProto = lodec.read(&mut *reader)?; let locators = if imsg::has_flag(self.header, flag::L) { let locs: Vec = self.codec.read(&mut *reader)?; @@ -124,7 +124,7 @@ where has_extensions = more; } - Ok(HelloInner { + Ok(HelloProto { version, zid, whatami, diff --git a/commons/zenoh-codec/src/scouting/scout.rs b/commons/zenoh-codec/src/scouting/scout.rs index 8449d74add..f4863e69b8 100644 --- a/commons/zenoh-codec/src/scouting/scout.rs +++ b/commons/zenoh-codec/src/scouting/scout.rs @@ -19,7 +19,7 @@ use zenoh_buffers::{ }; use zenoh_protocol::{ common::{imsg, ZExtUnknown}, - core::{whatami::WhatAmIMatcher, ZenohIdInner}, + core::{whatami::WhatAmIMatcher, ZenohIdProto}, scouting::{ id, scout::{flag, Scout}, @@ -93,7 +93,7 @@ where let zid = if imsg::has_flag(flags, flag::I) { let length = 1 + ((flags >> 4) as usize); let lodec = Zenoh080Length::new(length); - let zid: ZenohIdInner = lodec.read(&mut *reader)?; + let zid: ZenohIdProto = lodec.read(&mut *reader)?; Some(zid) } else { None diff --git a/commons/zenoh-codec/src/transport/init.rs b/commons/zenoh-codec/src/transport/init.rs index 09d449d2ef..c559fdbd51 100644 --- a/commons/zenoh-codec/src/transport/init.rs +++ b/commons/zenoh-codec/src/transport/init.rs @@ -18,7 +18,7 @@ use zenoh_buffers::{ }; use zenoh_protocol::{ common::{iext, imsg}, - core::{Resolution, WhatAmI, ZenohIdInner}, + core::{Resolution, WhatAmI, ZenohIdProto}, transport::{ batch_size, id, init::{ext, flag, InitAck, InitSyn}, @@ -160,7 +160,7 @@ where }; let length = 1 + ((flags >> 4) as usize); let lodec = Zenoh080Length::new(length); - let zid: ZenohIdInner = lodec.read(&mut *reader)?; + let zid: ZenohIdProto = lodec.read(&mut *reader)?; let mut resolution = Resolution::default(); let mut batch_size = batch_size::UNICAST.to_le_bytes(); @@ -373,7 +373,7 @@ where }; let length = 1 + ((flags >> 4) as usize); let lodec = Zenoh080Length::new(length); - let zid: ZenohIdInner = lodec.read(&mut *reader)?; + let zid: ZenohIdProto = lodec.read(&mut *reader)?; let mut resolution = Resolution::default(); let mut batch_size = batch_size::UNICAST.to_le_bytes(); diff --git a/commons/zenoh-codec/src/transport/join.rs b/commons/zenoh-codec/src/transport/join.rs index 65b51808cd..3f70d2ec8b 100644 --- a/commons/zenoh-codec/src/transport/join.rs +++ b/commons/zenoh-codec/src/transport/join.rs @@ -20,7 +20,7 @@ use zenoh_buffers::{ }; use zenoh_protocol::{ common::{iext, imsg, ZExtZBufHeader}, - core::{Priority, Resolution, WhatAmI, ZenohIdInner}, + core::{Priority, Resolution, WhatAmI, ZenohIdProto}, transport::{ batch_size, id, join::{ext, flag, Join}, @@ -242,7 +242,7 @@ where }; let length = 1 + ((flags >> 4) as usize); let lodec = Zenoh080Length::new(length); - let zid: ZenohIdInner = lodec.read(&mut *reader)?; + let zid: ZenohIdProto = lodec.read(&mut *reader)?; let mut resolution = Resolution::default(); let mut batch_size = batch_size::MULTICAST.to_le_bytes(); diff --git a/commons/zenoh-codec/src/zenoh/mod.rs b/commons/zenoh-codec/src/zenoh/mod.rs index 2ab1514280..3c8170adea 100644 --- a/commons/zenoh-codec/src/zenoh/mod.rs +++ b/commons/zenoh-codec/src/zenoh/mod.rs @@ -26,7 +26,7 @@ use zenoh_buffers::{ use zenoh_protocol::common::{iext, ZExtUnit}; use zenoh_protocol::{ common::{imsg, ZExtZBufHeader}, - core::{Encoding, EntityGlobalIdInner, EntityId, ZenohIdInner}, + core::{Encoding, EntityGlobalIdProto, EntityId, ZenohIdProto}, zenoh::{ext, id, PushBody, RequestBody, ResponseBody}, }; @@ -186,14 +186,14 @@ where let length = 1 + ((flags >> 4) as usize); let lodec = Zenoh080Length::new(length); - let zid: ZenohIdInner = lodec.read(&mut *reader)?; + let zid: ZenohIdProto = lodec.read(&mut *reader)?; let eid: EntityId = self.codec.read(&mut *reader)?; let sn: u32 = self.codec.read(&mut *reader)?; Ok(( ext::SourceInfoType { - id: EntityGlobalIdInner { zid, eid }, + id: EntityGlobalIdProto { zid, eid }, sn, }, more, diff --git a/commons/zenoh-codec/tests/codec.rs b/commons/zenoh-codec/tests/codec.rs index 388e84a7d1..1e1bbe18a3 100644 --- a/commons/zenoh-codec/tests/codec.rs +++ b/commons/zenoh-codec/tests/codec.rs @@ -272,7 +272,7 @@ fn codec_string_bounded() { #[test] fn codec_zid() { - run!(ZenohIdInner, ZenohIdInner::default()); + run!(ZenohIdProto, ZenohIdProto::default()); } #[test] @@ -348,7 +348,7 @@ fn codec_locator() { fn codec_timestamp() { run!(Timestamp, { let time = uhlc::NTP64(thread_rng().gen()); - let id = uhlc::ID::try_from(ZenohIdInner::rand().to_le_bytes()).unwrap(); + let id = uhlc::ID::try_from(ZenohIdProto::rand().to_le_bytes()).unwrap(); Timestamp::new(time, id) }); } @@ -447,7 +447,7 @@ fn codec_scout() { #[test] fn codec_hello() { - run!(HelloInner, HelloInner::rand()); + run!(HelloProto, HelloProto::rand()); } #[test] diff --git a/commons/zenoh-config/src/mode_dependent.rs b/commons/zenoh-config/src/mode_dependent.rs index d72fbc09ee..20bcb3481b 100644 --- a/commons/zenoh-config/src/mode_dependent.rs +++ b/commons/zenoh-config/src/mode_dependent.rs @@ -19,7 +19,7 @@ use serde::{ Deserialize, Serialize, }; pub use zenoh_protocol::core::{ - whatami, EndPoint, Locator, WhatAmI, WhatAmIMatcher, WhatAmIMatcherVisitor, ZenohIdInner, + whatami, EndPoint, Locator, WhatAmI, WhatAmIMatcher, WhatAmIMatcherVisitor, ZenohIdProto, }; pub trait ModeDependent { diff --git a/commons/zenoh-protocol/src/core/mod.rs b/commons/zenoh-protocol/src/core/mod.rs index 968b0ded0b..210ab01e87 100644 --- a/commons/zenoh-protocol/src/core/mod.rs +++ b/commons/zenoh-protocol/src/core/mod.rs @@ -62,9 +62,9 @@ pub use properties::*; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] -pub struct ZenohIdInner(uhlc::ID); +pub struct ZenohIdProto(uhlc::ID); -impl ZenohIdInner { +impl ZenohIdProto { pub const MAX_SIZE: usize = 16; #[inline] @@ -77,8 +77,8 @@ impl ZenohIdInner { self.0.to_le_bytes() } - pub fn rand() -> ZenohIdInner { - ZenohIdInner(uhlc::ID::rand()) + pub fn rand() -> ZenohIdProto { + ZenohIdProto(uhlc::ID::rand()) } pub fn into_keyexpr(self) -> OwnedKeyExpr { @@ -86,7 +86,7 @@ impl ZenohIdInner { } } -impl Default for ZenohIdInner { +impl Default for ZenohIdProto { fn default() -> Self { Self::rand() } @@ -97,7 +97,7 @@ impl Default for ZenohIdInner { Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Debug, Default, )] #[repr(transparent)] -pub struct ZenohId(ZenohIdInner); +pub struct ZenohId(ZenohIdProto); impl fmt::Display for ZenohId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -105,13 +105,13 @@ impl fmt::Display for ZenohId { } } -impl From for ZenohId { - fn from(id: ZenohIdInner) -> Self { +impl From for ZenohId { + fn from(id: ZenohIdProto) -> Self { Self(id) } } -impl From for ZenohIdInner { +impl From for ZenohIdProto { fn from(id: ZenohId) -> Self { id.0 } @@ -127,7 +127,7 @@ impl FromStr for ZenohId { type Err = zenoh_result::Error; fn from_str(s: &str) -> Result { - ZenohIdInner::from_str(s).map(|zid| zid.into()) + ZenohIdProto::from_str(s).map(|zid| zid.into()) } } @@ -160,7 +160,7 @@ impl fmt::Display for SizeError { macro_rules! derive_tryfrom { ($T: ty) => { - impl TryFrom<$T> for ZenohIdInner { + impl TryFrom<$T> for ZenohIdProto { type Error = zenoh_result::Error; fn try_from(val: $T) -> Result { match val.try_into() { @@ -205,7 +205,7 @@ derive_tryfrom!([u8; 16]); derive_tryfrom!(&[u8; 16]); derive_tryfrom!(&[u8]); -impl FromStr for ZenohIdInner { +impl FromStr for ZenohIdProto { type Err = zenoh_result::Error; fn from_str(s: &str) -> Result { @@ -218,37 +218,37 @@ impl FromStr for ZenohIdInner { let u: uhlc::ID = s .parse() .map_err(|e: uhlc::ParseIDError| zerror!("Invalid id: {} - {}", s, e.cause))?; - Ok(ZenohIdInner(u)) + Ok(ZenohIdProto(u)) } } -impl fmt::Debug for ZenohIdInner { +impl fmt::Debug for ZenohIdProto { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.0) } } -impl fmt::Display for ZenohIdInner { +impl fmt::Display for ZenohIdProto { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(self, f) } } // A PeerID can be converted into a Timestamp's ID -impl From<&ZenohIdInner> for uhlc::ID { - fn from(zid: &ZenohIdInner) -> Self { +impl From<&ZenohIdProto> for uhlc::ID { + fn from(zid: &ZenohIdProto) -> Self { zid.0 } } -impl From for uhlc::ID { - fn from(zid: ZenohIdInner) -> Self { +impl From for uhlc::ID { + fn from(zid: ZenohIdProto) -> Self { zid.0 } } -impl From for OwnedKeyExpr { - fn from(zid: ZenohIdInner) -> Self { +impl From for OwnedKeyExpr { + fn from(zid: ZenohIdProto) -> Self { // SAFETY: zid.to_string() returns an stringified hexadecimal // representation of the zid. Therefore, building a OwnedKeyExpr // by calling from_string_unchecked() is safe because it is @@ -257,13 +257,13 @@ impl From for OwnedKeyExpr { } } -impl From<&ZenohIdInner> for OwnedKeyExpr { - fn from(zid: &ZenohIdInner) -> Self { +impl From<&ZenohIdProto> for OwnedKeyExpr { + fn from(zid: &ZenohIdProto) -> Self { (*zid).into() } } -impl serde::Serialize for ZenohIdInner { +impl serde::Serialize for ZenohIdProto { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -272,7 +272,7 @@ impl serde::Serialize for ZenohIdInner { } } -impl<'de> serde::Deserialize<'de> for ZenohIdInner { +impl<'de> serde::Deserialize<'de> for ZenohIdProto { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -280,12 +280,12 @@ impl<'de> serde::Deserialize<'de> for ZenohIdInner { struct ZenohIdVisitor; impl<'de> serde::de::Visitor<'de> for ZenohIdVisitor { - type Value = ZenohIdInner; + type Value = ZenohIdProto; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str(&format!( "An hex string of 1-{} bytes", - ZenohIdInner::MAX_SIZE + ZenohIdProto::MAX_SIZE )) } @@ -320,17 +320,17 @@ pub type EntityId = u32; /// The global unique id of a zenoh entity. #[derive(Debug, Default, Copy, Clone, Eq, Hash, PartialEq)] -pub struct EntityGlobalIdInner { - pub zid: ZenohIdInner, +pub struct EntityGlobalIdProto { + pub zid: ZenohIdProto, pub eid: EntityId, } -impl EntityGlobalIdInner { +impl EntityGlobalIdProto { #[cfg(feature = "test")] pub fn rand() -> Self { use rand::Rng; Self { - zid: ZenohIdInner::rand(), + zid: ZenohIdProto::rand(), eid: rand::thread_rng().gen(), } } @@ -338,10 +338,10 @@ impl EntityGlobalIdInner { #[derive(Debug, Default, Copy, Clone, Eq, Hash, PartialEq)] #[repr(transparent)] -pub struct EntityGlobalId(EntityGlobalIdInner); +pub struct EntityGlobalId(EntityGlobalIdProto); impl EntityGlobalId { - pub fn zid(&self) -> ZenohIdInner { + pub fn zid(&self) -> ZenohIdProto { self.0.zid } @@ -350,8 +350,8 @@ impl EntityGlobalId { } } -impl From for EntityGlobalId { - fn from(id: EntityGlobalIdInner) -> Self { +impl From for EntityGlobalId { + fn from(id: EntityGlobalIdProto) -> Self { Self(id) } } diff --git a/commons/zenoh-protocol/src/network/mod.rs b/commons/zenoh-protocol/src/network/mod.rs index ad69e46efd..b9f3076581 100644 --- a/commons/zenoh-protocol/src/network/mod.rs +++ b/commons/zenoh-protocol/src/network/mod.rs @@ -221,7 +221,7 @@ pub mod ext { use crate::{ common::{imsg, ZExtZ64}, - core::{CongestionControl, EntityId, Priority, ZenohIdInner}, + core::{CongestionControl, EntityId, Priority, ZenohIdProto}, }; /// ```text @@ -366,7 +366,7 @@ pub mod ext { let mut rng = rand::thread_rng(); let time = uhlc::NTP64(rng.gen()); - let id = uhlc::ID::try_from(ZenohIdInner::rand().to_le_bytes()).unwrap(); + let id = uhlc::ID::try_from(ZenohIdProto::rand().to_le_bytes()).unwrap(); let timestamp = uhlc::Timestamp::new(time, id); Self { timestamp } } @@ -428,7 +428,7 @@ pub mod ext { /// +---------------+ #[derive(Debug, Clone, PartialEq, Eq)] pub struct EntityGlobalIdType { - pub zid: ZenohIdInner, + pub zid: ZenohIdProto, pub eid: EntityId, } @@ -438,7 +438,7 @@ pub mod ext { use rand::Rng; let mut rng = rand::thread_rng(); - let zid = ZenohIdInner::rand(); + let zid = ZenohIdProto::rand(); let eid: EntityId = rng.gen(); Self { zid, eid } } diff --git a/commons/zenoh-protocol/src/scouting/hello.rs b/commons/zenoh-protocol/src/scouting/hello.rs index 7ddbe567c4..80ed93dd62 100644 --- a/commons/zenoh-protocol/src/scouting/hello.rs +++ b/commons/zenoh-protocol/src/scouting/hello.rs @@ -14,7 +14,7 @@ use alloc::vec::Vec; use core::fmt; -use crate::core::{Locator, WhatAmI, ZenohIdInner}; +use crate::core::{Locator, WhatAmI, ZenohIdProto}; /// # Hello message /// @@ -100,14 +100,14 @@ pub mod flag { } #[derive(Debug, Clone, PartialEq, Eq)] -pub struct HelloInner { +pub struct HelloProto { pub version: u8, pub whatami: WhatAmI, - pub zid: ZenohIdInner, + pub zid: ZenohIdProto, pub locators: Vec, } -impl HelloInner { +impl HelloProto { #[cfg(feature = "test")] pub fn rand() -> Self { use rand::Rng; @@ -115,7 +115,7 @@ impl HelloInner { let mut rng = rand::thread_rng(); let version: u8 = rng.gen(); - let zid = ZenohIdInner::default(); + let zid = ZenohIdProto::default(); let whatami = WhatAmI::rand(); let locators = if rng.gen_bool(0.5) { Vec::from_iter((1..5).map(|_| Locator::rand())) @@ -132,7 +132,7 @@ impl HelloInner { } /// A zenoh Hello message. -pub struct Hello(HelloInner); +pub struct Hello(HelloProto); impl Hello { /// Get the locators of this Hello message. @@ -141,7 +141,7 @@ impl Hello { } /// Get the zenoh id of this Hello message. - pub fn zid(&self) -> ZenohIdInner { + pub fn zid(&self) -> ZenohIdProto { self.0.zid } @@ -151,8 +151,8 @@ impl Hello { } } -impl From for Hello { - fn from(inner: HelloInner) -> Self { +impl From for Hello { + fn from(inner: HelloProto) -> Self { Hello(inner) } } diff --git a/commons/zenoh-protocol/src/scouting/mod.rs b/commons/zenoh-protocol/src/scouting/mod.rs index 5ddf17ecd9..2cb5d1c0f0 100644 --- a/commons/zenoh-protocol/src/scouting/mod.rs +++ b/commons/zenoh-protocol/src/scouting/mod.rs @@ -14,7 +14,7 @@ pub mod hello; pub mod scout; -pub use hello::HelloInner; +pub use hello::HelloProto; pub use scout::Scout; pub mod id { @@ -27,7 +27,7 @@ pub mod id { #[derive(Debug, Clone, PartialEq, Eq)] pub enum ScoutingBody { Scout(Scout), - Hello(HelloInner), + Hello(HelloProto), } #[derive(Debug, Clone, PartialEq, Eq)] @@ -46,7 +46,7 @@ impl ScoutingMessage { match rng.gen_range(0..2) { 0 => ScoutingBody::Scout(Scout::rand()), - 1 => ScoutingBody::Hello(HelloInner::rand()), + 1 => ScoutingBody::Hello(HelloProto::rand()), _ => unreachable!(), } .into() @@ -69,8 +69,8 @@ impl From for ScoutingMessage { } } -impl From for ScoutingMessage { - fn from(hello: HelloInner) -> Self { +impl From for ScoutingMessage { + fn from(hello: HelloProto) -> Self { ScoutingBody::Hello(hello).into() } } diff --git a/commons/zenoh-protocol/src/scouting/scout.rs b/commons/zenoh-protocol/src/scouting/scout.rs index b92fbfb7bc..6d2b49f335 100644 --- a/commons/zenoh-protocol/src/scouting/scout.rs +++ b/commons/zenoh-protocol/src/scouting/scout.rs @@ -11,7 +11,7 @@ // Contributors: // ZettaScale Zenoh Team, // -use crate::core::{whatami::WhatAmIMatcher, ZenohIdInner}; +use crate::core::{whatami::WhatAmIMatcher, ZenohIdProto}; /// # Scout message /// @@ -75,7 +75,7 @@ pub mod flag { pub struct Scout { pub version: u8, pub what: WhatAmIMatcher, - pub zid: Option, + pub zid: Option, } impl Scout { @@ -87,7 +87,7 @@ impl Scout { let version: u8 = rng.gen(); let what = WhatAmIMatcher::rand(); - let zid = rng.gen_bool(0.5).then_some(ZenohIdInner::rand()); + let zid = rng.gen_bool(0.5).then_some(ZenohIdProto::rand()); Self { version, what, zid } } } diff --git a/commons/zenoh-protocol/src/transport/init.rs b/commons/zenoh-protocol/src/transport/init.rs index e41ea99acf..7e56bfd770 100644 --- a/commons/zenoh-protocol/src/transport/init.rs +++ b/commons/zenoh-protocol/src/transport/init.rs @@ -14,7 +14,7 @@ use zenoh_buffers::ZSlice; use crate::{ - core::{Resolution, WhatAmI, ZenohIdInner}, + core::{Resolution, WhatAmI, ZenohIdProto}, transport::BatchSize, }; @@ -111,7 +111,7 @@ pub mod flag { pub struct InitSyn { pub version: u8, pub whatami: WhatAmI, - pub zid: ZenohIdInner, + pub zid: ZenohIdProto, pub resolution: Resolution, pub batch_size: BatchSize, pub ext_qos: Option, @@ -167,7 +167,7 @@ impl InitSyn { let version: u8 = rng.gen(); let whatami = WhatAmI::rand(); - let zid = ZenohIdInner::default(); + let zid = ZenohIdProto::default(); let resolution = Resolution::rand(); let batch_size: BatchSize = rng.gen(); let ext_qos = rng.gen_bool(0.5).then_some(ZExtUnit::rand()); @@ -199,7 +199,7 @@ impl InitSyn { pub struct InitAck { pub version: u8, pub whatami: WhatAmI, - pub zid: ZenohIdInner, + pub zid: ZenohIdProto, pub resolution: Resolution, pub batch_size: BatchSize, pub cookie: ZSlice, @@ -223,7 +223,7 @@ impl InitAck { let version: u8 = rng.gen(); let whatami = WhatAmI::rand(); - let zid = ZenohIdInner::default(); + let zid = ZenohIdProto::default(); let resolution = if rng.gen_bool(0.5) { Resolution::default() } else { diff --git a/commons/zenoh-protocol/src/transport/join.rs b/commons/zenoh-protocol/src/transport/join.rs index 78f9b8bded..e1e3f97c33 100644 --- a/commons/zenoh-protocol/src/transport/join.rs +++ b/commons/zenoh-protocol/src/transport/join.rs @@ -14,7 +14,7 @@ use core::time::Duration; use crate::{ - core::{Priority, Resolution, WhatAmI, ZenohIdInner}, + core::{Priority, Resolution, WhatAmI, ZenohIdProto}, transport::{BatchSize, PrioritySn}, }; @@ -105,7 +105,7 @@ pub mod flag { pub struct Join { pub version: u8, pub whatami: WhatAmI, - pub zid: ZenohIdInner, + pub zid: ZenohIdProto, pub resolution: Resolution, pub batch_size: BatchSize, pub lease: Duration, @@ -142,7 +142,7 @@ impl Join { let version: u8 = rng.gen(); let whatami = WhatAmI::rand(); - let zid = ZenohIdInner::default(); + let zid = ZenohIdProto::default(); let resolution = Resolution::rand(); let batch_size: BatchSize = rng.gen(); let lease = if rng.gen_bool(0.5) { diff --git a/commons/zenoh-protocol/src/zenoh/del.rs b/commons/zenoh-protocol/src/zenoh/del.rs index ced867020e..d4c6b8b3ac 100644 --- a/commons/zenoh-protocol/src/zenoh/del.rs +++ b/commons/zenoh-protocol/src/zenoh/del.rs @@ -66,12 +66,12 @@ impl Del { pub fn rand() -> Self { use rand::Rng; - use crate::{common::iext, core::ZenohIdInner}; + use crate::{common::iext, core::ZenohIdProto}; let mut rng = rand::thread_rng(); let timestamp = rng.gen_bool(0.5).then_some({ let time = uhlc::NTP64(rng.gen()); - let id = uhlc::ID::try_from(ZenohIdInner::rand().to_le_bytes()).unwrap(); + let id = uhlc::ID::try_from(ZenohIdProto::rand().to_le_bytes()).unwrap(); Timestamp::new(time, id) }); let ext_sinfo = rng.gen_bool(0.5).then_some(ext::SourceInfoType::rand()); diff --git a/commons/zenoh-protocol/src/zenoh/mod.rs b/commons/zenoh-protocol/src/zenoh/mod.rs index 44fb26cc32..eeb1a63c1d 100644 --- a/commons/zenoh-protocol/src/zenoh/mod.rs +++ b/commons/zenoh-protocol/src/zenoh/mod.rs @@ -136,7 +136,7 @@ impl From for ResponseBody { pub mod ext { use zenoh_buffers::ZBuf; - use crate::core::{Encoding, EntityGlobalIdInner}; + use crate::core::{Encoding, EntityGlobalIdProto}; /// 7 6 5 4 3 2 1 0 /// +-+-+-+-+-+-+-+-+ @@ -150,7 +150,7 @@ pub mod ext { /// +---------------+ #[derive(Debug, Clone, PartialEq, Eq)] pub struct SourceInfoType { - pub id: EntityGlobalIdInner, + pub id: EntityGlobalIdProto, pub sn: u32, } @@ -160,7 +160,7 @@ pub mod ext { use rand::Rng; let mut rng = rand::thread_rng(); - let id = EntityGlobalIdInner::rand(); + let id = EntityGlobalIdProto::rand(); let sn: u32 = rng.gen(); Self { id, sn } } diff --git a/commons/zenoh-protocol/src/zenoh/put.rs b/commons/zenoh-protocol/src/zenoh/put.rs index 55680e8c0b..91a0a8f50b 100644 --- a/commons/zenoh-protocol/src/zenoh/put.rs +++ b/commons/zenoh-protocol/src/zenoh/put.rs @@ -84,12 +84,12 @@ impl Put { pub fn rand() -> Self { use rand::Rng; - use crate::{common::iext, core::ZenohIdInner}; + use crate::{common::iext, core::ZenohIdProto}; let mut rng = rand::thread_rng(); let timestamp = rng.gen_bool(0.5).then_some({ let time = uhlc::NTP64(rng.gen()); - let id = uhlc::ID::try_from(ZenohIdInner::rand().to_le_bytes()).unwrap(); + let id = uhlc::ID::try_from(ZenohIdProto::rand().to_le_bytes()).unwrap(); Timestamp::new(time, id) }); let encoding = Encoding::rand(); diff --git a/io/zenoh-transport/src/lib.rs b/io/zenoh-transport/src/lib.rs index 7fbdb19fc3..bfdd79685d 100644 --- a/io/zenoh-transport/src/lib.rs +++ b/io/zenoh-transport/src/lib.rs @@ -34,7 +34,7 @@ pub use manager::*; use serde::Serialize; use zenoh_link::Link; use zenoh_protocol::{ - core::{WhatAmI, ZenohIdInner}, + core::{WhatAmI, ZenohIdProto}, network::NetworkMessage, }; use zenoh_result::ZResult; @@ -108,7 +108,7 @@ impl TransportMulticastEventHandler for DummyTransportMulticastEventHandler { #[derive(Clone, Debug, Serialize, PartialEq, Eq)] #[serde(rename = "Transport")] pub struct TransportPeer { - pub zid: ZenohIdInner, + pub zid: ZenohIdProto, pub whatami: WhatAmI, pub is_qos: bool, #[serde(skip)] diff --git a/io/zenoh-transport/src/manager.rs b/io/zenoh-transport/src/manager.rs index 33f90bf5a3..deba9cf6f6 100644 --- a/io/zenoh-transport/src/manager.rs +++ b/io/zenoh-transport/src/manager.rs @@ -19,7 +19,7 @@ use zenoh_config::{Config, LinkRxConf, QueueConf, QueueSizeConf}; use zenoh_crypto::{BlockCipher, PseudoRng}; use zenoh_link::NewLinkChannelSender; use zenoh_protocol::{ - core::{EndPoint, Field, Locator, Priority, Resolution, WhatAmI, ZenohIdInner}, + core::{EndPoint, Field, Locator, Priority, Resolution, WhatAmI, ZenohIdProto}, transport::BatchSize, VERSION, }; @@ -45,7 +45,7 @@ use crate::multicast::manager::{ /// ``` /// use std::sync::Arc; /// use std::time::Duration; -/// use zenoh_protocol::core::{ZenohIdInner, Resolution, Field, Bits, WhatAmI, whatami}; +/// use zenoh_protocol::core::{ZenohIdProto, Resolution, Field, Bits, WhatAmI, whatami}; /// use zenoh_transport::*; /// use zenoh_result::ZResult; /// @@ -85,7 +85,7 @@ use crate::multicast::manager::{ /// let mut resolution = Resolution::default(); /// resolution.set(Field::FrameSN, Bits::U8); /// let manager = TransportManager::builder() -/// .zid(ZenohIdInner::rand().into()) +/// .zid(ZenohIdProto::rand().into()) /// .whatami(WhatAmI::Peer) /// .batch_size(1_024) // Use a batch size of 1024 bytes /// .resolution(resolution) // Use a sequence number resolution of 128 @@ -96,7 +96,7 @@ use crate::multicast::manager::{ pub struct TransportManagerConfig { pub version: u8, - pub zid: ZenohIdInner, + pub zid: ZenohIdProto, pub whatami: WhatAmI, pub resolution: Resolution, pub batch_size: BatchSize, @@ -125,7 +125,7 @@ pub struct TransportManagerParams { pub struct TransportManagerBuilder { version: u8, - zid: ZenohIdInner, + zid: ZenohIdProto, whatami: WhatAmI, resolution: Resolution, batch_size: BatchSize, @@ -150,7 +150,7 @@ impl TransportManagerBuilder { self } - pub fn zid(mut self, zid: ZenohIdInner) -> Self { + pub fn zid(mut self, zid: ZenohIdProto) -> Self { self.zid = zid; self } @@ -335,7 +335,7 @@ impl Default for TransportManagerBuilder { let wait_before_drop = *queue.congestion_control().wait_before_drop(); Self { version: VERSION, - zid: ZenohIdInner::rand(), + zid: ZenohIdProto::rand(), whatami: zenoh_config::defaults::mode, resolution: Resolution::default(), batch_size: BatchSize::MAX, @@ -424,7 +424,7 @@ impl TransportManager { TransportManagerBuilder::default() } - pub fn zid(&self) -> ZenohIdInner { + pub fn zid(&self) -> ZenohIdProto { self.config.zid } diff --git a/io/zenoh-transport/src/multicast/link.rs b/io/zenoh-transport/src/multicast/link.rs index f7d163cdef..382109be0b 100644 --- a/io/zenoh-transport/src/multicast/link.rs +++ b/io/zenoh-transport/src/multicast/link.rs @@ -23,7 +23,7 @@ use zenoh_buffers::{BBuf, ZSlice, ZSliceBuffer}; use zenoh_core::{zcondfeat, zlock}; use zenoh_link::{Link, LinkMulticast, Locator}; use zenoh_protocol::{ - core::{Bits, Priority, Resolution, WhatAmI, ZenohIdInner}, + core::{Bits, Priority, Resolution, WhatAmI, ZenohIdProto}, transport::{BatchSize, Close, Join, PrioritySn, TransportMessage, TransportSn}, }; use zenoh_result::{zerror, ZResult}; @@ -251,7 +251,7 @@ impl fmt::Debug for TransportLinkMulticastRx { /**************************************/ pub(super) struct TransportLinkMulticastConfigUniversal { pub(super) version: u8, - pub(super) zid: ZenohIdInner, + pub(super) zid: ZenohIdProto, pub(super) whatami: WhatAmI, pub(super) lease: Duration, pub(super) join_interval: Duration, diff --git a/io/zenoh-transport/src/multicast/manager.rs b/io/zenoh-transport/src/multicast/manager.rs index 2abe630d14..fed0194b77 100644 --- a/io/zenoh-transport/src/multicast/manager.rs +++ b/io/zenoh-transport/src/multicast/manager.rs @@ -22,7 +22,7 @@ use zenoh_config::{Config, LinkTxConf}; use zenoh_core::zasynclock; use zenoh_link::*; use zenoh_protocol::{ - core::{Parameters, ZenohIdInner}, + core::{Parameters, ZenohIdProto}, transport::close, }; use zenoh_result::{bail, zerror, ZResult}; @@ -266,7 +266,7 @@ impl TransportManager { super::establishment::open_link(self, link).await } - pub async fn get_transport_multicast(&self, zid: &ZenohIdInner) -> Option { + pub async fn get_transport_multicast(&self, zid: &ZenohIdProto) -> Option { for t in zasynclock!(self.state.multicast.transports).values() { if t.get_peers().iter().any(|p| p.zid == *zid) { return Some(t.into()); diff --git a/io/zenoh-transport/src/multicast/transport.rs b/io/zenoh-transport/src/multicast/transport.rs index 8b140dced4..f0dfec4813 100644 --- a/io/zenoh-transport/src/multicast/transport.rs +++ b/io/zenoh-transport/src/multicast/transport.rs @@ -24,7 +24,7 @@ use tokio_util::sync::CancellationToken; use zenoh_core::{zcondfeat, zread, zwrite}; use zenoh_link::{Link, Locator}; use zenoh_protocol::{ - core::{Bits, Field, Priority, Resolution, WhatAmI, ZenohIdInner}, + core::{Bits, Field, Priority, Resolution, WhatAmI, ZenohIdProto}, transport::{batch_size, close, Close, Join, TransportMessage}, }; use zenoh_result::{bail, ZResult}; @@ -53,7 +53,7 @@ use crate::{ pub(super) struct TransportMulticastPeer { pub(super) version: u8, pub(super) locator: Locator, - pub(super) zid: ZenohIdInner, + pub(super) zid: ZenohIdProto, pub(super) whatami: WhatAmI, pub(super) resolution: Resolution, pub(super) lease: Duration, diff --git a/io/zenoh-transport/src/unicast/establishment/accept.rs b/io/zenoh-transport/src/unicast/establishment/accept.rs index 487fcc2328..ed4890d7d2 100644 --- a/io/zenoh-transport/src/unicast/establishment/accept.rs +++ b/io/zenoh-transport/src/unicast/establishment/accept.rs @@ -22,7 +22,7 @@ use zenoh_core::{zasynclock, zcondfeat, zerror}; use zenoh_crypto::{BlockCipher, PseudoRng}; use zenoh_link::LinkUnicast; use zenoh_protocol::{ - core::{Field, Resolution, WhatAmI, ZenohIdInner}, + core::{Field, Resolution, WhatAmI, ZenohIdProto}, transport::{ batch_size, close::{self, Close}, @@ -80,7 +80,7 @@ struct RecvInitSynIn { mine_version: u8, } struct RecvInitSynOut { - other_zid: ZenohIdInner, + other_zid: ZenohIdProto, other_whatami: WhatAmI, #[cfg(feature = "shared-memory")] ext_shm: Option, @@ -89,9 +89,9 @@ struct RecvInitSynOut { // InitAck struct SendInitAckIn { mine_version: u8, - mine_zid: ZenohIdInner, + mine_zid: ZenohIdProto, mine_whatami: WhatAmI, - other_zid: ZenohIdInner, + other_zid: ZenohIdProto, other_whatami: WhatAmI, #[cfg(feature = "shared-memory")] ext_shm: Option, @@ -107,7 +107,7 @@ struct RecvOpenSynIn { cookie_nonce: u64, } struct RecvOpenSynOut { - other_zid: ZenohIdInner, + other_zid: ZenohIdProto, other_whatami: WhatAmI, other_lease: Duration, other_initial_sn: TransportSn, @@ -115,9 +115,9 @@ struct RecvOpenSynOut { // OpenAck struct SendOpenAckIn { - mine_zid: ZenohIdInner, + mine_zid: ZenohIdProto, mine_lease: Duration, - other_zid: ZenohIdInner, + other_zid: ZenohIdProto, } struct SendOpenAckOut { open_ack: OpenAck, diff --git a/io/zenoh-transport/src/unicast/establishment/cookie.rs b/io/zenoh-transport/src/unicast/establishment/cookie.rs index b94a1cabe1..4220f8e08b 100644 --- a/io/zenoh-transport/src/unicast/establishment/cookie.rs +++ b/io/zenoh-transport/src/unicast/establishment/cookie.rs @@ -20,7 +20,7 @@ use zenoh_buffers::{ use zenoh_codec::{RCodec, WCodec, Zenoh080}; use zenoh_crypto::{BlockCipher, PseudoRng}; use zenoh_protocol::{ - core::{Resolution, WhatAmI, ZenohIdInner}, + core::{Resolution, WhatAmI, ZenohIdProto}, transport::BatchSize, }; @@ -28,7 +28,7 @@ use crate::unicast::establishment::ext; #[derive(Debug, PartialEq)] pub(crate) struct Cookie { - pub(crate) zid: ZenohIdInner, + pub(crate) zid: ZenohIdProto, pub(crate) whatami: WhatAmI, pub(crate) resolution: Resolution, pub(crate) batch_size: BatchSize, @@ -82,7 +82,7 @@ where type Error = DidntRead; fn read(self, reader: &mut R) -> Result { - let zid: ZenohIdInner = self.read(&mut *reader)?; + let zid: ZenohIdProto = self.read(&mut *reader)?; let wai: u8 = self.read(&mut *reader)?; let whatami = WhatAmI::try_from(wai).map_err(|_| DidntRead)?; let resolution: u8 = self.read(&mut *reader)?; @@ -173,7 +173,7 @@ impl Cookie { let mut rng = rand::thread_rng(); Self { - zid: ZenohIdInner::default(), + zid: ZenohIdProto::default(), whatami: WhatAmI::rand(), resolution: Resolution::rand(), batch_size: rng.gen(), diff --git a/io/zenoh-transport/src/unicast/establishment/mod.rs b/io/zenoh-transport/src/unicast/establishment/mod.rs index 355747e0df..ca46b40ed1 100644 --- a/io/zenoh-transport/src/unicast/establishment/mod.rs +++ b/io/zenoh-transport/src/unicast/establishment/mod.rs @@ -23,7 +23,7 @@ use sha3::{ Shake128, }; use zenoh_protocol::{ - core::{Field, Resolution, ZenohIdInner}, + core::{Field, Resolution, ZenohIdProto}, transport::TransportSn, }; @@ -102,8 +102,8 @@ pub trait AcceptFsm { /* FUNCTIONS */ /*************************************/ pub(super) fn compute_sn( - zid1: ZenohIdInner, - zid2: ZenohIdInner, + zid1: ZenohIdProto, + zid2: ZenohIdProto, resolution: Resolution, ) -> TransportSn { // Create a random yet deterministic initial_sn. diff --git a/io/zenoh-transport/src/unicast/establishment/open.rs b/io/zenoh-transport/src/unicast/establishment/open.rs index a48c2b9717..2857d1cc75 100644 --- a/io/zenoh-transport/src/unicast/establishment/open.rs +++ b/io/zenoh-transport/src/unicast/establishment/open.rs @@ -20,7 +20,7 @@ use zenoh_core::zasynclock; use zenoh_core::{zcondfeat, zerror}; use zenoh_link::LinkUnicast; use zenoh_protocol::{ - core::{Field, Resolution, WhatAmI, ZenohIdInner}, + core::{Field, Resolution, WhatAmI, ZenohIdProto}, transport::{ batch_size, close, BatchSize, Close, InitSyn, OpenSyn, TransportBody, TransportMessage, TransportSn, @@ -75,13 +75,13 @@ struct State { // InitSyn struct SendInitSynIn { mine_version: u8, - mine_zid: ZenohIdInner, + mine_zid: ZenohIdProto, mine_whatami: WhatAmI, } // InitAck struct RecvInitAckOut { - other_zid: ZenohIdInner, + other_zid: ZenohIdProto, other_whatami: WhatAmI, other_cookie: ZSlice, #[cfg(feature = "shared-memory")] @@ -90,9 +90,9 @@ struct RecvInitAckOut { // OpenSyn struct SendOpenSynIn { - mine_zid: ZenohIdInner, + mine_zid: ZenohIdProto, mine_lease: Duration, - other_zid: ZenohIdInner, + other_zid: ZenohIdProto, other_cookie: ZSlice, #[cfg(feature = "shared-memory")] ext_shm: Option, diff --git a/io/zenoh-transport/src/unicast/lowlatency/transport.rs b/io/zenoh-transport/src/unicast/lowlatency/transport.rs index e8e8fa8ad0..749c5507aa 100644 --- a/io/zenoh-transport/src/unicast/lowlatency/transport.rs +++ b/io/zenoh-transport/src/unicast/lowlatency/transport.rs @@ -22,7 +22,7 @@ use tokio_util::{sync::CancellationToken, task::TaskTracker}; use zenoh_core::{zasynclock, zasyncread, zasyncwrite, zread, zwrite}; use zenoh_link::Link; use zenoh_protocol::{ - core::{WhatAmI, ZenohIdInner}, + core::{WhatAmI, ZenohIdProto}, network::NetworkMessage, transport::{close, Close, TransportBodyLowLatency, TransportMessageLowLatency, TransportSn}, }; @@ -183,7 +183,7 @@ impl TransportUnicastTrait for TransportUnicastLowlatency { vec![] } - fn get_zid(&self) -> ZenohIdInner { + fn get_zid(&self) -> ZenohIdProto { self.config.zid } diff --git a/io/zenoh-transport/src/unicast/manager.rs b/io/zenoh-transport/src/unicast/manager.rs index 04fce06270..52de702603 100644 --- a/io/zenoh-transport/src/unicast/manager.rs +++ b/io/zenoh-transport/src/unicast/manager.rs @@ -30,7 +30,7 @@ use zenoh_core::{zasynclock, zcondfeat}; use zenoh_crypto::PseudoRng; use zenoh_link::*; use zenoh_protocol::{ - core::{Parameters, ZenohIdInner}, + core::{Parameters, ZenohIdProto}, transport::{close, TransportSn}, }; use zenoh_result::{bail, zerror, ZResult}; @@ -79,7 +79,7 @@ pub struct TransportManagerStateUnicast { // Established listeners pub(super) protocols: Arc>>, // Established transports - pub(super) transports: Arc>>>, + pub(super) transports: Arc>>>, // Multilink #[cfg(feature = "transport_multilink")] pub(super) multilink: Arc, @@ -510,7 +510,7 @@ impl TransportManager { link: LinkUnicastWithOpenAck, other_initial_sn: TransportSn, other_lease: Duration, - mut guard: AsyncMutexGuard<'_, HashMap>>, + mut guard: AsyncMutexGuard<'_, HashMap>>, ) -> InitTransportResult { macro_rules! link_error { ($s:expr, $reason:expr) => { @@ -707,7 +707,7 @@ impl TransportManager { super::establishment::open::open_link(link, self).await } - pub async fn get_transport_unicast(&self, peer: &ZenohIdInner) -> Option { + pub async fn get_transport_unicast(&self, peer: &ZenohIdProto) -> Option { zasynclock!(self.state.unicast.transports) .get(peer) .map(|t| TransportUnicast(Arc::downgrade(t))) @@ -720,7 +720,7 @@ impl TransportManager { .collect() } - pub(super) async fn del_transport_unicast(&self, peer: &ZenohIdInner) -> ZResult<()> { + pub(super) async fn del_transport_unicast(&self, peer: &ZenohIdProto) -> ZResult<()> { zasynclock!(self.state.unicast.transports) .remove(peer) .ok_or_else(|| { diff --git a/io/zenoh-transport/src/unicast/mod.rs b/io/zenoh-transport/src/unicast/mod.rs index 001290a3f5..04162de10a 100644 --- a/io/zenoh-transport/src/unicast/mod.rs +++ b/io/zenoh-transport/src/unicast/mod.rs @@ -32,7 +32,7 @@ pub use manager::*; use zenoh_core::zcondfeat; use zenoh_link::Link; use zenoh_protocol::{ - core::{Bits, WhatAmI, ZenohIdInner}, + core::{Bits, WhatAmI, ZenohIdProto}, network::NetworkMessage, transport::{close, TransportSn}, }; @@ -48,7 +48,7 @@ use crate::shm::TransportShmConfig; /*************************************/ #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) struct TransportConfigUnicast { - pub(crate) zid: ZenohIdInner, + pub(crate) zid: ZenohIdProto, pub(crate) whatami: WhatAmI, pub(crate) sn_resolution: Bits, pub(crate) tx_initial_sn: TransportSn, @@ -74,7 +74,7 @@ impl TransportUnicast { } #[inline(always)] - pub fn get_zid(&self) -> ZResult { + pub fn get_zid(&self) -> ZResult { let transport = self.get_inner()?; Ok(transport.get_zid()) } diff --git a/io/zenoh-transport/src/unicast/transport_unicast_inner.rs b/io/zenoh-transport/src/unicast/transport_unicast_inner.rs index 98e8dc1885..c7821aac9c 100644 --- a/io/zenoh-transport/src/unicast/transport_unicast_inner.rs +++ b/io/zenoh-transport/src/unicast/transport_unicast_inner.rs @@ -18,7 +18,7 @@ use async_trait::async_trait; use tokio::sync::MutexGuard as AsyncMutexGuard; use zenoh_link::Link; use zenoh_protocol::{ - core::{WhatAmI, ZenohIdInner}, + core::{WhatAmI, ZenohIdProto}, network::NetworkMessage, transport::TransportSn, }; @@ -52,7 +52,7 @@ pub(crate) trait TransportUnicastTrait: Send + Sync { fn set_callback(&self, callback: Arc); async fn get_alive(&self) -> AsyncMutexGuard<'_, bool>; - fn get_zid(&self) -> ZenohIdInner; + fn get_zid(&self) -> ZenohIdProto; fn get_whatami(&self) -> WhatAmI; fn get_callback(&self) -> Option>; fn get_links(&self) -> Vec; diff --git a/io/zenoh-transport/src/unicast/universal/transport.rs b/io/zenoh-transport/src/unicast/universal/transport.rs index 6d1d492c55..6a122d258e 100644 --- a/io/zenoh-transport/src/unicast/universal/transport.rs +++ b/io/zenoh-transport/src/unicast/universal/transport.rs @@ -22,7 +22,7 @@ use tokio::sync::{Mutex as AsyncMutex, MutexGuard as AsyncMutexGuard}; use zenoh_core::{zasynclock, zcondfeat, zread, zwrite}; use zenoh_link::Link; use zenoh_protocol::{ - core::{Priority, WhatAmI, ZenohIdInner}, + core::{Priority, WhatAmI, ZenohIdProto}, network::NetworkMessage, transport::{close, Close, PrioritySn, TransportMessage, TransportSn}, }; @@ -320,7 +320,7 @@ impl TransportUnicastTrait for TransportUnicastUniversal { zasynclock!(self.alive) } - fn get_zid(&self) -> ZenohIdInner { + fn get_zid(&self) -> ZenohIdProto { self.config.zid } diff --git a/io/zenoh-transport/tests/endpoints.rs b/io/zenoh-transport/tests/endpoints.rs index 09d2281d78..f4ddbd6ec4 100644 --- a/io/zenoh-transport/tests/endpoints.rs +++ b/io/zenoh-transport/tests/endpoints.rs @@ -16,7 +16,7 @@ use std::{any::Any, convert::TryFrom, sync::Arc, time::Duration}; use zenoh_core::ztimeout; use zenoh_link::{EndPoint, Link}; use zenoh_protocol::{ - core::{WhatAmI, ZenohIdInner}, + core::{WhatAmI, ZenohIdProto}, network::NetworkMessage, }; use zenoh_result::ZResult; @@ -74,7 +74,7 @@ async fn run(endpoints: &[EndPoint]) { // Create the transport manager let sm = TransportManager::builder() .whatami(WhatAmI::Peer) - .zid(ZenohIdInner::try_from([1]).unwrap()) + .zid(ZenohIdProto::try_from([1]).unwrap()) .build(Arc::new(SH)) .unwrap(); diff --git a/io/zenoh-transport/tests/multicast_compression.rs b/io/zenoh-transport/tests/multicast_compression.rs index a83d62fad3..129f79d55e 100644 --- a/io/zenoh-transport/tests/multicast_compression.rs +++ b/io/zenoh-transport/tests/multicast_compression.rs @@ -30,7 +30,7 @@ mod tests { use zenoh_protocol::{ core::{ Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, - ZenohIdInner, + ZenohIdProto, }, network::{ push::{ @@ -145,8 +145,8 @@ mod tests { endpoint: &EndPoint, ) -> (TransportMulticastPeer, TransportMulticastPeer) { // Define peer01 and peer02 IDs - let peer01_id = ZenohIdInner::try_from([1]).unwrap(); - let peer02_id = ZenohIdInner::try_from([2]).unwrap(); + let peer01_id = ZenohIdProto::try_from([1]).unwrap(); + let peer02_id = ZenohIdProto::try_from([2]).unwrap(); // Create the peer01 transport manager let peer01_handler = Arc::new(SHPeer::default()); diff --git a/io/zenoh-transport/tests/multicast_transport.rs b/io/zenoh-transport/tests/multicast_transport.rs index 29c73e3bf9..0ffefb59b2 100644 --- a/io/zenoh-transport/tests/multicast_transport.rs +++ b/io/zenoh-transport/tests/multicast_transport.rs @@ -31,7 +31,7 @@ mod tests { use zenoh_protocol::{ core::{ Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, - ZenohIdInner, + ZenohIdProto, }, network::{ push::{ @@ -144,8 +144,8 @@ mod tests { endpoint: &EndPoint, ) -> (TransportMulticastPeer, TransportMulticastPeer) { // Define peer01 and peer02 IDs - let peer01_id = ZenohIdInner::try_from([1]).unwrap(); - let peer02_id = ZenohIdInner::try_from([2]).unwrap(); + let peer01_id = ZenohIdProto::try_from([1]).unwrap(); + let peer02_id = ZenohIdProto::try_from([2]).unwrap(); // Create the peer01 transport manager let peer01_handler = Arc::new(SHPeer::default()); diff --git a/io/zenoh-transport/tests/transport_whitelist.rs b/io/zenoh-transport/tests/transport_whitelist.rs index 042f38abe6..121db5b5d6 100644 --- a/io/zenoh-transport/tests/transport_whitelist.rs +++ b/io/zenoh-transport/tests/transport_whitelist.rs @@ -16,7 +16,7 @@ use std::{any::Any, convert::TryFrom, iter::FromIterator, sync::Arc, time::Durat use zenoh_core::ztimeout; use zenoh_link::Link; use zenoh_protocol::{ - core::{EndPoint, ZenohIdInner}, + core::{EndPoint, ZenohIdProto}, network::NetworkMessage, }; use zenoh_result::ZResult; @@ -68,7 +68,7 @@ impl TransportPeerEventHandler for SCRouter { async fn run(endpoints: &[EndPoint]) { // Define client and router IDs - let router_id = ZenohIdInner::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([1]).unwrap(); // Create the router transport manager println!(">>> Transport Whitelist [1a1]"); diff --git a/io/zenoh-transport/tests/unicast_authenticator.rs b/io/zenoh-transport/tests/unicast_authenticator.rs index 78780739c7..87f2174598 100644 --- a/io/zenoh-transport/tests/unicast_authenticator.rs +++ b/io/zenoh-transport/tests/unicast_authenticator.rs @@ -16,7 +16,7 @@ use std::{any::Any, sync::Arc, time::Duration}; use zenoh_core::{zasyncwrite, ztimeout}; use zenoh_link::Link; use zenoh_protocol::{ - core::{EndPoint, WhatAmI, ZenohIdInner}, + core::{EndPoint, WhatAmI, ZenohIdProto}, network::NetworkMessage, }; use zenoh_result::ZResult; @@ -111,7 +111,7 @@ async fn auth_pubkey(endpoint: &EndPoint, lowlatency_transport: bool) { }; // Create the transport transport manager for the client 01 - let client01_id = ZenohIdInner::try_from([2]).unwrap(); + let client01_id = ZenohIdProto::try_from([2]).unwrap(); let n = BigUint::from_bytes_le(&[ 0x41, 0x74, 0xc6, 0x40, 0x18, 0x63, 0xbd, 0x59, 0xe6, 0x0d, 0xe9, 0x23, 0x3e, 0x95, 0xca, @@ -170,7 +170,7 @@ async fn auth_pubkey(endpoint: &EndPoint, lowlatency_transport: bool) { .unwrap(); // Create the transport transport manager for the client 02 - let client02_id = ZenohIdInner::try_from([3]).unwrap(); + let client02_id = ZenohIdProto::try_from([3]).unwrap(); let n = BigUint::from_bytes_le(&[ 0xd1, 0x36, 0xcf, 0x94, 0xda, 0x04, 0x7e, 0x9f, 0x53, 0x39, 0xb8, 0x7b, 0x53, 0x3a, 0xe6, @@ -229,7 +229,7 @@ async fn auth_pubkey(endpoint: &EndPoint, lowlatency_transport: bool) { .unwrap(); // Create the transport transport manager for the client 03 with the same key as client 02 - let client03_id = ZenohIdInner::try_from([4]).unwrap(); + let client03_id = ZenohIdProto::try_from([4]).unwrap(); let mut auth = Auth::empty(); auth.set_pubkey(Some(AuthPubKey::new( client02_pub_key.clone().into(), @@ -249,7 +249,7 @@ async fn auth_pubkey(endpoint: &EndPoint, lowlatency_transport: bool) { .unwrap(); // Create the router transport manager - let router_id = ZenohIdInner::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([1]).unwrap(); let router_handler = Arc::new(SHRouterAuthenticator::new()); let n = BigUint::from_bytes_le(&[ 0x31, 0xd1, 0xfc, 0x7e, 0x70, 0x5f, 0xd7, 0xe3, 0xcc, 0xa4, 0xca, 0xcb, 0x38, 0x84, 0x2f, @@ -414,11 +414,11 @@ async fn auth_usrpwd(endpoint: &EndPoint, lowlatency_transport: bool) { }; /* [CLIENT] */ - let client01_id = ZenohIdInner::try_from([2]).unwrap(); + let client01_id = ZenohIdProto::try_from([2]).unwrap(); let user01 = "user01".to_string(); let password01 = "password01".to_string(); - let client02_id = ZenohIdInner::try_from([3]).unwrap(); + let client02_id = ZenohIdProto::try_from([3]).unwrap(); let user02 = "invalid".to_string(); let password02 = "invalid".to_string(); @@ -427,7 +427,7 @@ async fn auth_usrpwd(endpoint: &EndPoint, lowlatency_transport: bool) { let password03 = "password03".to_string(); /* [ROUTER] */ - let router_id = ZenohIdInner::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([1]).unwrap(); let router_handler = Arc::new(SHRouterAuthenticator::new()); // Create the router transport manager let mut auth_usrpwd_router = AuthUsrPwd::new(None); diff --git a/io/zenoh-transport/tests/unicast_compression.rs b/io/zenoh-transport/tests/unicast_compression.rs index b836dc9374..7c2443c5d9 100644 --- a/io/zenoh-transport/tests/unicast_compression.rs +++ b/io/zenoh-transport/tests/unicast_compression.rs @@ -29,7 +29,7 @@ mod tests { use zenoh_protocol::{ core::{ Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, - ZenohIdInner, + ZenohIdProto, }, network::{ push::ext::{NodeIdType, QoSType}, @@ -169,8 +169,8 @@ mod tests { TransportUnicast, ) { // Define client and router IDs - let client_id = ZenohIdInner::try_from([1]).unwrap(); - let router_id = ZenohIdInner::try_from([2]).unwrap(); + let client_id = ZenohIdProto::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([2]).unwrap(); // Create the router transport manager let router_handler = Arc::new(SHRouter::default()); diff --git a/io/zenoh-transport/tests/unicast_concurrent.rs b/io/zenoh-transport/tests/unicast_concurrent.rs index bba6f4d1a0..183f8a7163 100644 --- a/io/zenoh-transport/tests/unicast_concurrent.rs +++ b/io/zenoh-transport/tests/unicast_concurrent.rs @@ -24,7 +24,7 @@ use tokio::sync::Barrier; use zenoh_core::ztimeout; use zenoh_link::Link; use zenoh_protocol::{ - core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdInner}, + core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdProto}, network::{ push::{ ext::{NodeIdType, QoSType}, @@ -108,8 +108,8 @@ impl TransportPeerEventHandler for MHPeer { async fn transport_concurrent(endpoint01: Vec, endpoint02: Vec) { /* [Peers] */ - let peer_id01 = ZenohIdInner::try_from([2]).unwrap(); - let peer_id02 = ZenohIdInner::try_from([3]).unwrap(); + let peer_id01 = ZenohIdProto::try_from([2]).unwrap(); + let peer_id02 = ZenohIdProto::try_from([3]).unwrap(); // Create the peer01 transport manager let peer_sh01 = Arc::new(SHPeer::new()); diff --git a/io/zenoh-transport/tests/unicast_defragmentation.rs b/io/zenoh-transport/tests/unicast_defragmentation.rs index 2c9ddbbf07..fc54180c96 100644 --- a/io/zenoh-transport/tests/unicast_defragmentation.rs +++ b/io/zenoh-transport/tests/unicast_defragmentation.rs @@ -17,7 +17,7 @@ use zenoh_core::ztimeout; use zenoh_protocol::{ core::{ Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, - ZenohIdInner, + ZenohIdProto, }, network::{ push::{ @@ -38,8 +38,8 @@ const MSG_DEFRAG_BUF: usize = 128_000; async fn run(endpoint: &EndPoint, channel: Channel, msg_size: usize) { // Define client and router IDs - let client_id = ZenohIdInner::try_from([1]).unwrap(); - let router_id = ZenohIdInner::try_from([2]).unwrap(); + let client_id = ZenohIdProto::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([2]).unwrap(); // Create the router transport manager let router_manager = TransportManager::builder() diff --git a/io/zenoh-transport/tests/unicast_intermittent.rs b/io/zenoh-transport/tests/unicast_intermittent.rs index b292f194c8..a2cb1e2d12 100644 --- a/io/zenoh-transport/tests/unicast_intermittent.rs +++ b/io/zenoh-transport/tests/unicast_intermittent.rs @@ -25,7 +25,7 @@ use std::{ use zenoh_core::ztimeout; use zenoh_link::Link; use zenoh_protocol::{ - core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdInner}, + core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdProto}, network::{ push::{ ext::{NodeIdType, QoSType}, @@ -148,7 +148,7 @@ impl TransportPeerEventHandler for SCClient { async fn transport_intermittent(endpoint: &EndPoint, lowlatency_transport: bool) { /* [ROUTER] */ - let router_id = ZenohIdInner::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([1]).unwrap(); let router_handler = Arc::new(SHRouterIntermittent); // Create the router transport manager @@ -168,9 +168,9 @@ async fn transport_intermittent(endpoint: &EndPoint, lowlatency_transport: bool) .unwrap(); /* [CLIENT] */ - let client01_id = ZenohIdInner::try_from([2]).unwrap(); - let client02_id = ZenohIdInner::try_from([3]).unwrap(); - let client03_id = ZenohIdInner::try_from([4]).unwrap(); + let client01_id = ZenohIdProto::try_from([2]).unwrap(); + let client02_id = ZenohIdProto::try_from([3]).unwrap(); + let client03_id = ZenohIdProto::try_from([4]).unwrap(); // Create the transport transport manager for the first client let counter = Arc::new(AtomicUsize::new(0)); diff --git a/io/zenoh-transport/tests/unicast_multilink.rs b/io/zenoh-transport/tests/unicast_multilink.rs index d8429b44c1..6fc0864fe2 100644 --- a/io/zenoh-transport/tests/unicast_multilink.rs +++ b/io/zenoh-transport/tests/unicast_multilink.rs @@ -17,7 +17,7 @@ mod tests { use zenoh_core::ztimeout; use zenoh_link::EndPoint; - use zenoh_protocol::core::{WhatAmI, ZenohIdInner}; + use zenoh_protocol::core::{WhatAmI, ZenohIdProto}; use zenoh_result::ZResult; use zenoh_transport::{ multicast::TransportMulticast, unicast::TransportUnicast, DummyTransportPeerEventHandler, @@ -77,7 +77,7 @@ mod tests { async fn multilink_transport(endpoint: &EndPoint) { /* [ROUTER] */ - let router_id = ZenohIdInner::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([1]).unwrap(); let router_handler = Arc::new(SHRouterOpenClose); // Create the router transport manager @@ -92,8 +92,8 @@ mod tests { .unwrap(); /* [CLIENT] */ - let client01_id = ZenohIdInner::try_from([2]).unwrap(); - let client02_id = ZenohIdInner::try_from([3]).unwrap(); + let client01_id = ZenohIdProto::try_from([2]).unwrap(); + let client02_id = ZenohIdProto::try_from([3]).unwrap(); // Create the transport transport manager for the first client let unicast = TransportManager::config_unicast() diff --git a/io/zenoh-transport/tests/unicast_openclose.rs b/io/zenoh-transport/tests/unicast_openclose.rs index f2c1cdc7fa..8909d74402 100644 --- a/io/zenoh-transport/tests/unicast_openclose.rs +++ b/io/zenoh-transport/tests/unicast_openclose.rs @@ -15,7 +15,7 @@ use std::{convert::TryFrom, sync::Arc, time::Duration}; use zenoh_core::ztimeout; use zenoh_link::EndPoint; -use zenoh_protocol::core::{WhatAmI, ZenohIdInner}; +use zenoh_protocol::core::{WhatAmI, ZenohIdProto}; use zenoh_result::ZResult; use zenoh_transport::{ multicast::TransportMulticast, @@ -90,7 +90,7 @@ async fn openclose_transport( lowlatency_transport: bool, ) { /* [ROUTER] */ - let router_id = ZenohIdInner::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([1]).unwrap(); let router_handler = Arc::new(SHRouterOpenClose); // Create the router transport manager @@ -110,8 +110,8 @@ async fn openclose_transport( .unwrap(); /* [CLIENT] */ - let client01_id = ZenohIdInner::try_from([2]).unwrap(); - let client02_id = ZenohIdInner::try_from([3]).unwrap(); + let client01_id = ZenohIdProto::try_from([2]).unwrap(); + let client02_id = ZenohIdProto::try_from([3]).unwrap(); // Create the transport transport manager for the first client let unicast = make_transport_manager_builder( diff --git a/io/zenoh-transport/tests/unicast_priorities.rs b/io/zenoh-transport/tests/unicast_priorities.rs index 533ef9217c..708a9fad3b 100644 --- a/io/zenoh-transport/tests/unicast_priorities.rs +++ b/io/zenoh-transport/tests/unicast_priorities.rs @@ -25,7 +25,7 @@ use std::{ use zenoh_core::ztimeout; use zenoh_link::Link; use zenoh_protocol::{ - core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdInner}, + core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdProto}, network::{ push::{ ext::{NodeIdType, QoSType}, @@ -200,8 +200,8 @@ async fn open_transport_unicast( TransportUnicast, ) { // Define client and router IDs - let client_id = ZenohIdInner::try_from([1]).unwrap(); - let router_id = ZenohIdInner::try_from([2]).unwrap(); + let client_id = ZenohIdProto::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([2]).unwrap(); // Create the router transport manager let router_handler = Arc::new(SHRouter::new()); diff --git a/io/zenoh-transport/tests/unicast_shm.rs b/io/zenoh-transport/tests/unicast_shm.rs index 7a0da48cca..8c06a17f6d 100644 --- a/io/zenoh-transport/tests/unicast_shm.rs +++ b/io/zenoh-transport/tests/unicast_shm.rs @@ -27,7 +27,7 @@ mod tests { use zenoh_core::ztimeout; use zenoh_link::Link; use zenoh_protocol::{ - core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdInner}, + core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdProto}, network::{ push::ext::{NodeIdType, QoSType}, NetworkBody, NetworkMessage, Push, @@ -153,9 +153,9 @@ mod tests { println!("Transport SHM [0a]: {endpoint:?}"); // Define client and router IDs - let peer_shm01 = ZenohIdInner::try_from([1]).unwrap(); - let peer_shm02 = ZenohIdInner::try_from([2]).unwrap(); - let peer_net01 = ZenohIdInner::try_from([3]).unwrap(); + let peer_shm01 = ZenohIdProto::try_from([1]).unwrap(); + let peer_shm02 = ZenohIdProto::try_from([2]).unwrap(); + let peer_net01 = ZenohIdProto::try_from([3]).unwrap(); // create SHM provider let backend = PosixShmProviderBackend::builder() diff --git a/io/zenoh-transport/tests/unicast_simultaneous.rs b/io/zenoh-transport/tests/unicast_simultaneous.rs index a9a2a1d548..4f529c3b74 100644 --- a/io/zenoh-transport/tests/unicast_simultaneous.rs +++ b/io/zenoh-transport/tests/unicast_simultaneous.rs @@ -26,7 +26,7 @@ mod tests { use zenoh_core::ztimeout; use zenoh_link::Link; use zenoh_protocol::{ - core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdInner}, + core::{CongestionControl, Encoding, EndPoint, Priority, WhatAmI, ZenohIdProto}, network::{ push::ext::{NodeIdType, QoSType}, NetworkMessage, Push, @@ -47,12 +47,12 @@ mod tests { // Transport Handler for the router struct SHPeer { - zid: ZenohIdInner, + zid: ZenohIdProto, count: Arc, } impl SHPeer { - fn new(zid: ZenohIdInner) -> Self { + fn new(zid: ZenohIdProto) -> Self { Self { zid, count: Arc::new(AtomicUsize::new(0)), @@ -136,8 +136,8 @@ mod tests { async fn transport_simultaneous(endpoint01: Vec, endpoint02: Vec) { /* [Peers] */ - let peer_id01 = ZenohIdInner::try_from([2]).unwrap(); - let peer_id02 = ZenohIdInner::try_from([3]).unwrap(); + let peer_id01 = ZenohIdProto::try_from([2]).unwrap(); + let peer_id02 = ZenohIdProto::try_from([3]).unwrap(); // Create the peer01 transport manager let peer_sh01 = Arc::new(SHPeer::new(peer_id01)); diff --git a/io/zenoh-transport/tests/unicast_time.rs b/io/zenoh-transport/tests/unicast_time.rs index 5a01655eb3..5c62235371 100644 --- a/io/zenoh-transport/tests/unicast_time.rs +++ b/io/zenoh-transport/tests/unicast_time.rs @@ -19,7 +19,7 @@ use std::{ use zenoh_core::ztimeout; use zenoh_link::EndPoint; -use zenoh_protocol::core::{WhatAmI, ZenohIdInner}; +use zenoh_protocol::core::{WhatAmI, ZenohIdProto}; use zenoh_result::ZResult; use zenoh_transport::{ multicast::TransportMulticast, @@ -96,7 +96,7 @@ async fn time_transport( println!(">>> Universal transport"); } /* [ROUTER] */ - let router_id = ZenohIdInner::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([1]).unwrap(); let router_handler = Arc::new(SHRouterOpenClose); // Create the router transport manager @@ -116,7 +116,7 @@ async fn time_transport( .unwrap(); /* [CLIENT] */ - let client01_id = ZenohIdInner::try_from([2]).unwrap(); + let client01_id = ZenohIdProto::try_from([2]).unwrap(); // Create the transport transport manager for the first client let unicast = make_transport_manager_builder( diff --git a/io/zenoh-transport/tests/unicast_transport.rs b/io/zenoh-transport/tests/unicast_transport.rs index c6ab3896be..b49b863991 100644 --- a/io/zenoh-transport/tests/unicast_transport.rs +++ b/io/zenoh-transport/tests/unicast_transport.rs @@ -27,7 +27,7 @@ use zenoh_link::Link; use zenoh_protocol::{ core::{ Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, - ZenohIdInner, + ZenohIdProto, }, network::{ push::ext::{NodeIdType, QoSType}, @@ -355,8 +355,8 @@ async fn open_transport_unicast( TransportUnicast, ) { // Define client and router IDs - let client_id = ZenohIdInner::try_from([1]).unwrap(); - let router_id = ZenohIdInner::try_from([2]).unwrap(); + let client_id = ZenohIdProto::try_from([1]).unwrap(); + let router_id = ZenohIdProto::try_from([2]).unwrap(); // Create the router transport manager let router_handler = Arc::new(SHRouter::default()); diff --git a/zenoh/src/api/publisher.rs b/zenoh/src/api/publisher.rs index 1f9298e456..54f3dc8a02 100644 --- a/zenoh/src/api/publisher.rs +++ b/zenoh/src/api/publisher.rs @@ -35,7 +35,7 @@ use { crate::api::handlers::{Callback, DefaultHandler, IntoHandler}, crate::api::sample::SourceInfo, zenoh_protocol::core::EntityGlobalId, - zenoh_protocol::core::EntityGlobalIdInner, + zenoh_protocol::core::EntityGlobalIdProto, }; use super::{ @@ -158,7 +158,7 @@ impl<'a> Publisher<'a> { /// ``` #[zenoh_macros::unstable] pub fn id(&self) -> EntityGlobalId { - EntityGlobalIdInner { + EntityGlobalIdProto { zid: self.session.zid().into(), eid: self.id, } diff --git a/zenoh/src/api/query.rs b/zenoh/src/api/query.rs index 05fdef5675..0b761789b4 100644 --- a/zenoh/src/api/query.rs +++ b/zenoh/src/api/query.rs @@ -20,7 +20,7 @@ use std::{ use zenoh_core::{Resolvable, Wait}; use zenoh_keyexpr::OwnedKeyExpr; -use zenoh_protocol::core::{CongestionControl, ZenohIdInner}; +use zenoh_protocol::core::{CongestionControl, ZenohIdProto}; use zenoh_result::ZResult; #[zenoh_macros::unstable] @@ -84,7 +84,7 @@ impl Default for QueryConsolidation { #[derive(Clone, Debug)] pub struct Reply { pub(crate) result: Result, - pub(crate) replier_id: ZenohIdInner, + pub(crate) replier_id: ZenohIdProto, } impl Reply { @@ -104,7 +104,7 @@ impl Reply { } /// Gets the id of the zenoh instance that answered this Reply. - pub fn replier_id(&self) -> ZenohIdInner { + pub fn replier_id(&self) -> ZenohIdProto { self.replier_id } } diff --git a/zenoh/src/api/queryable.rs b/zenoh/src/api/queryable.rs index 25e01a5a2c..4c68b524b2 100644 --- a/zenoh/src/api/queryable.rs +++ b/zenoh/src/api/queryable.rs @@ -21,7 +21,7 @@ use std::{ use uhlc::Timestamp; use zenoh_core::{Resolvable, Resolve, Wait}; use zenoh_protocol::{ - core::{CongestionControl, EntityId, WireExpr, ZenohIdInner}, + core::{CongestionControl, EntityId, WireExpr, ZenohIdProto}, network::{response, Mapping, RequestId, Response, ResponseFinal}, zenoh::{self, reply::ReplyBody, Del, Put, ResponseBody}, }; @@ -29,7 +29,7 @@ use zenoh_result::ZResult; #[zenoh_macros::unstable] use { super::{query::ReplyKeyExpr, sample::SourceInfo}, - zenoh_protocol::core::EntityGlobalIdInner, + zenoh_protocol::core::EntityGlobalIdProto, }; use super::{ @@ -54,7 +54,7 @@ pub(crate) struct QueryInner { pub(crate) key_expr: KeyExpr<'static>, pub(crate) parameters: Parameters<'static>, pub(crate) qid: RequestId, - pub(crate) zid: ZenohIdInner, + pub(crate) zid: ZenohIdProto, pub(crate) primitives: Arc, } @@ -870,8 +870,8 @@ impl<'a, Handler> Queryable<'a, Handler> { /// # } /// ``` #[zenoh_macros::unstable] - pub fn id(&self) -> EntityGlobalIdInner { - EntityGlobalIdInner { + pub fn id(&self) -> EntityGlobalIdProto { + EntityGlobalIdProto { zid: self.queryable.session.zid().into(), eid: self.queryable.state.id, } diff --git a/zenoh/src/api/sample.rs b/zenoh/src/api/sample.rs index 0631bfba59..a65e42048c 100644 --- a/zenoh/src/api/sample.rs +++ b/zenoh/src/api/sample.rs @@ -18,7 +18,7 @@ use std::{convert::TryFrom, fmt}; #[cfg(feature = "unstable")] use serde::Serialize; use zenoh_protocol::{ - core::{CongestionControl, EntityGlobalIdInner, Timestamp}, + core::{CongestionControl, EntityGlobalIdProto, Timestamp}, network::declare::ext::QoSType, }; @@ -52,7 +52,7 @@ pub(crate) struct DataInfo { pub kind: SampleKind, pub encoding: Option, pub timestamp: Option, - pub source_id: Option, + pub source_id: Option, pub source_sn: Option, pub qos: QoS, } @@ -137,7 +137,7 @@ impl DataInfoIntoSample for Option { #[derive(Debug, Clone)] pub struct SourceInfo { /// The [`EntityGlobalId`] of the zenoh entity that published the concerned [`Sample`]. - pub source_id: Option, + pub source_id: Option, /// The sequence number of the [`Sample`] from the source. pub source_sn: Option, } @@ -145,12 +145,12 @@ pub struct SourceInfo { #[test] #[cfg(feature = "unstable")] fn source_info_stack_size() { - use zenoh_protocol::core::ZenohIdInner; + use zenoh_protocol::core::ZenohIdProto; use crate::api::sample::{SourceInfo, SourceSn}; - assert_eq!(std::mem::size_of::(), 16); - assert_eq!(std::mem::size_of::>(), 17); + assert_eq!(std::mem::size_of::(), 16); + assert_eq!(std::mem::size_of::>(), 17); assert_eq!(std::mem::size_of::>(), 16); assert_eq!(std::mem::size_of::(), 17 + 16 + 7); } diff --git a/zenoh/src/api/session.rs b/zenoh/src/api/session.rs index e6a1405240..436c1bbd55 100644 --- a/zenoh/src/api/session.rs +++ b/zenoh/src/api/session.rs @@ -2196,7 +2196,7 @@ impl Primitives for Session { }; let replier_id = match e.ext_sinfo { Some(info) => info.id.zid, - None => zenoh_protocol::core::ZenohIdInner::rand(), + None => zenoh_protocol::core::ZenohIdProto::rand(), }; let new_reply = Reply { replier_id, @@ -2314,7 +2314,7 @@ impl Primitives for Session { let sample = info.into_sample(key_expr.into_owned(), payload, attachment); let new_reply = Reply { result: Ok(sample), - replier_id: zenoh_protocol::core::ZenohIdInner::rand(), // TODO + replier_id: zenoh_protocol::core::ZenohIdProto::rand(), // TODO }; let callback = match query.reception_mode { diff --git a/zenoh/src/api/subscriber.rs b/zenoh/src/api/subscriber.rs index c7e5324bc9..f7d5268772 100644 --- a/zenoh/src/api/subscriber.rs +++ b/zenoh/src/api/subscriber.rs @@ -21,7 +21,7 @@ use std::{ use zenoh_core::{Resolvable, Wait}; #[cfg(feature = "unstable")] -use zenoh_protocol::core::EntityGlobalIdInner; +use zenoh_protocol::core::EntityGlobalIdProto; use zenoh_protocol::{core::Reliability, network::declare::subscriber::ext::SubscriberInfo}; use zenoh_result::ZResult; @@ -458,8 +458,8 @@ impl<'a, Handler> Subscriber<'a, Handler> { /// # } /// ``` #[zenoh_macros::unstable] - pub fn id(&self) -> EntityGlobalIdInner { - EntityGlobalIdInner { + pub fn id(&self) -> EntityGlobalIdProto { + EntityGlobalIdProto { zid: self.subscriber.session.zid().into(), eid: self.subscriber.state.id, } diff --git a/zenoh/src/net/codec/linkstate.rs b/zenoh/src/net/codec/linkstate.rs index 1bfc2a17e1..7ee150d8bb 100644 --- a/zenoh/src/net/codec/linkstate.rs +++ b/zenoh/src/net/codec/linkstate.rs @@ -20,7 +20,7 @@ use zenoh_buffers::{ use zenoh_codec::{RCodec, WCodec, Zenoh080}; use zenoh_protocol::{ common::imsg, - core::{Locator, WhatAmI, ZenohIdInner}, + core::{Locator, WhatAmI, ZenohIdProto}, }; use super::Zenoh080Routing; @@ -85,7 +85,7 @@ where let psid: u64 = codec.read(&mut *reader)?; let sn: u64 = codec.read(&mut *reader)?; let zid = if imsg::has_option(options, linkstate::PID) { - let zid: ZenohIdInner = codec.read(&mut *reader)?; + let zid: ZenohIdProto = codec.read(&mut *reader)?; Some(zid) } else { None diff --git a/zenoh/src/net/protocol/linkstate.rs b/zenoh/src/net/protocol/linkstate.rs index bae990ea3c..cd8d1a91bf 100644 --- a/zenoh/src/net/protocol/linkstate.rs +++ b/zenoh/src/net/protocol/linkstate.rs @@ -11,7 +11,7 @@ // Contributors: // ZettaScale Zenoh Team, // -use zenoh_protocol::core::{Locator, WhatAmI, ZenohIdInner}; +use zenoh_protocol::core::{Locator, WhatAmI, ZenohIdProto}; pub const PID: u64 = 1; // 0x01 pub const WAI: u64 = 1 << 1; // 0x02 @@ -37,7 +37,7 @@ pub const LOC: u64 = 1 << 2; // 0x04 pub(crate) struct LinkState { pub(crate) psid: u64, pub(crate) sn: u64, - pub(crate) zid: Option, + pub(crate) zid: Option, pub(crate) whatami: Option, pub(crate) locators: Option>, pub(crate) links: Vec, @@ -56,7 +56,7 @@ impl LinkState { let psid: u64 = rng.gen(); let sn: u64 = rng.gen(); let zid = if rng.gen_bool(0.5) { - Some(ZenohIdInner::default()) + Some(ZenohIdProto::default()) } else { None }; diff --git a/zenoh/src/net/routing/dispatcher/face.rs b/zenoh/src/net/routing/dispatcher/face.rs index a894904c66..7c92d5f709 100644 --- a/zenoh/src/net/routing/dispatcher/face.rs +++ b/zenoh/src/net/routing/dispatcher/face.rs @@ -20,7 +20,7 @@ use std::{ use tokio_util::sync::CancellationToken; use zenoh_protocol::{ - core::{ExprId, WhatAmI, ZenohIdInner}, + core::{ExprId, WhatAmI, ZenohIdProto}, network::{ declare::ext, interest::{InterestId, InterestMode, InterestOptions}, @@ -55,7 +55,7 @@ pub(crate) struct InterestState { pub struct FaceState { pub(crate) id: usize, - pub(crate) zid: ZenohIdInner, + pub(crate) zid: ZenohIdProto, pub(crate) whatami: WhatAmI, #[cfg(feature = "stats")] pub(crate) stats: Option>, @@ -76,7 +76,7 @@ impl FaceState { #[allow(clippy::too_many_arguments)] // @TODO fix warning pub(crate) fn new( id: usize, - zid: ZenohIdInner, + zid: ZenohIdProto, whatami: WhatAmI, #[cfg(feature = "stats")] stats: Option>, primitives: Arc, diff --git a/zenoh/src/net/routing/dispatcher/tables.rs b/zenoh/src/net/routing/dispatcher/tables.rs index b795a5bd81..9221522c00 100644 --- a/zenoh/src/net/routing/dispatcher/tables.rs +++ b/zenoh/src/net/routing/dispatcher/tables.rs @@ -21,7 +21,7 @@ use std::{ use uhlc::HLC; use zenoh_config::{unwrap_or_default, Config}; use zenoh_protocol::{ - core::{ExprId, WhatAmI, ZenohIdInner}, + core::{ExprId, WhatAmI, ZenohIdProto}, network::Mapping, }; use zenoh_result::ZResult; @@ -61,7 +61,7 @@ impl<'a> RoutingExpr<'a> { } pub struct Tables { - pub(crate) zid: ZenohIdInner, + pub(crate) zid: ZenohIdProto, pub(crate) whatami: WhatAmI, pub(crate) face_counter: usize, #[allow(dead_code)] @@ -79,7 +79,7 @@ pub struct Tables { impl Tables { pub fn new( - zid: ZenohIdInner, + zid: ZenohIdProto, whatami: WhatAmI, hlc: Option>, config: &Config, @@ -145,7 +145,7 @@ impl Tables { } #[inline] - pub(crate) fn get_face(&self, zid: &ZenohIdInner) -> Option<&Arc> { + pub(crate) fn get_face(&self, zid: &ZenohIdProto) -> Option<&Arc> { self.faces.values().find(|face| face.zid == *zid) } diff --git a/zenoh/src/net/routing/hat/linkstate_peer/mod.rs b/zenoh/src/net/routing/hat/linkstate_peer/mod.rs index b7fab02bb0..32e4cb30e9 100644 --- a/zenoh/src/net/routing/hat/linkstate_peer/mod.rs +++ b/zenoh/src/net/routing/hat/linkstate_peer/mod.rs @@ -27,7 +27,7 @@ use std::{ use zenoh_config::{unwrap_or_default, ModeDependent, WhatAmI, WhatAmIMatcher}; use zenoh_protocol::{ common::ZExtBody, - core::ZenohIdInner, + core::ZenohIdProto, network::{ declare::{queryable::ext::QueryableInfoType, QueryableId, SubscriberId}, interest::InterestId, @@ -463,9 +463,9 @@ impl HatBaseTrait for HatCode { } struct HatContext { - router_subs: HashSet, - peer_subs: HashSet, - peer_qabls: HashMap, + router_subs: HashSet, + peer_subs: HashSet, + peer_qabls: HashMap, } impl HatContext { @@ -504,7 +504,7 @@ impl HatFace { } } -fn get_peer(tables: &Tables, face: &Arc, nodeid: NodeId) -> Option { +fn get_peer(tables: &Tables, face: &Arc, nodeid: NodeId) -> Option { match hat!(tables) .peers_net .as_ref() diff --git a/zenoh/src/net/routing/hat/linkstate_peer/network.rs b/zenoh/src/net/routing/hat/linkstate_peer/network.rs index 9a9a8ce818..4ca3dcfb92 100644 --- a/zenoh/src/net/routing/hat/linkstate_peer/network.rs +++ b/zenoh/src/net/routing/hat/linkstate_peer/network.rs @@ -27,7 +27,7 @@ use zenoh_codec::WCodec; use zenoh_link::Locator; use zenoh_protocol::{ common::ZExtBody, - core::{WhatAmI, WhatAmIMatcher, ZenohIdInner}, + core::{WhatAmI, WhatAmIMatcher, ZenohIdProto}, network::{oam, oam::id::OAM_LINKSTATE, NetworkBody, NetworkMessage, Oam}, }; use zenoh_transport::unicast::TransportUnicast; @@ -48,11 +48,11 @@ struct Details { #[derive(Clone)] pub(super) struct Node { - pub(super) zid: ZenohIdInner, + pub(super) zid: ZenohIdProto, pub(super) whatami: Option, pub(super) locators: Option>, pub(super) sn: u64, - pub(super) links: Vec, + pub(super) links: Vec, } impl std::fmt::Debug for Node { @@ -63,8 +63,8 @@ impl std::fmt::Debug for Node { pub(super) struct Link { pub(super) transport: TransportUnicast, - zid: ZenohIdInner, - mappings: VecMap, + zid: ZenohIdProto, + mappings: VecMap, local_mappings: VecMap, } @@ -80,12 +80,12 @@ impl Link { } #[inline] - pub(super) fn set_zid_mapping(&mut self, psid: u64, zid: ZenohIdInner) { + pub(super) fn set_zid_mapping(&mut self, psid: u64, zid: ZenohIdProto) { self.mappings.insert(psid.try_into().unwrap(), zid); } #[inline] - pub(super) fn get_zid(&self, psid: &u64) -> Option<&ZenohIdInner> { + pub(super) fn get_zid(&self, psid: &u64) -> Option<&ZenohIdProto> { self.mappings.get((*psid).try_into().unwrap()) } @@ -132,7 +132,7 @@ impl Network { #[allow(clippy::too_many_arguments)] pub(super) fn new( name: String, - zid: ZenohIdInner, + zid: ZenohIdProto, runtime: Runtime, full_linkstate: bool, router_peers_failover_brokering: bool, @@ -177,7 +177,7 @@ impl Network { } #[inline] - pub(super) fn get_idx(&self, zid: &ZenohIdInner) -> Option { + pub(super) fn get_idx(&self, zid: &ZenohIdProto) -> Option { self.graph .node_indices() .find(|idx| self.graph[*idx].zid == *zid) @@ -189,7 +189,7 @@ impl Network { } #[inline] - pub(super) fn get_link_from_zid(&self, zid: &ZenohIdInner) -> Option<&Link> { + pub(super) fn get_link_from_zid(&self, zid: &ZenohIdProto) -> Option<&Link> { self.links.values().find(|link| link.zid == *zid) } @@ -347,7 +347,7 @@ impl Network { pub(super) fn link_states( &mut self, link_states: Vec, - src: ZenohIdInner, + src: ZenohIdProto, ) -> Changes { tracing::trace!("{} Received from {} raw: {:?}", self.name, src, link_states); let strong_runtime = self.runtime.upgrade().unwrap(); @@ -413,7 +413,7 @@ impl Network { let link_states = link_states .into_iter() .map(|(zid, wai, locs, sn, links)| { - let links: Vec = links + let links: Vec = links .iter() .filter_map(|l| { if let Some(zid) = src_link.get_zid(l) { @@ -563,7 +563,7 @@ impl Network { } }, ) - .collect::, NodeIndex, bool)>>(); + .collect::, NodeIndex, bool)>>(); // Add/remove edges from graph let mut reintroduced_nodes = vec![]; @@ -615,7 +615,7 @@ impl Network { let link_states = link_states .into_iter() .filter(|ls| !removed.iter().any(|(idx, _)| idx == &ls.1)) - .collect::, NodeIndex, bool)>>(); + .collect::, NodeIndex, bool)>>(); if !self.autoconnect.is_empty() { // Connect discovered peers @@ -654,8 +654,8 @@ impl Network { #[allow(clippy::type_complexity)] // This is only used here if !link_states.is_empty() { let (new_idxs, updated_idxs): ( - Vec<(Vec, NodeIndex, bool)>, - Vec<(Vec, NodeIndex, bool)>, + Vec<(Vec, NodeIndex, bool)>, + Vec<(Vec, NodeIndex, bool)>, ) = link_states.into_iter().partition(|(_, _, new)| *new); let new_idxs = new_idxs .into_iter() @@ -819,7 +819,7 @@ impl Network { free_index } - pub(super) fn remove_link(&mut self, zid: &ZenohIdInner) -> Vec<(NodeIndex, Node)> { + pub(super) fn remove_link(&mut self, zid: &ZenohIdProto) -> Vec<(NodeIndex, Node)> { tracing::trace!("{} remove_link {}", self.name, zid); self.links.retain(|_, link| link.zid != *zid); self.graph[self.idx].links.retain(|link| *link != *zid); diff --git a/zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs b/zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs index e0c9c201d6..b75cb26cc1 100644 --- a/zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs +++ b/zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs @@ -19,7 +19,7 @@ use std::{ use petgraph::graph::NodeIndex; use zenoh_protocol::{ - core::{key_expr::OwnedKeyExpr, Reliability, WhatAmI, ZenohIdInner}, + core::{key_expr::OwnedKeyExpr, Reliability, WhatAmI, ZenohIdProto}, network::{ declare::{ common::ext::WireExprType, ext, subscriber::ext::SubscriberInfo, Declare, DeclareBody, @@ -179,7 +179,7 @@ fn propagate_sourced_subscription( res: &Arc, sub_info: &SubscriberInfo, src_face: Option<&Arc>, - source: &ZenohIdInner, + source: &ZenohIdProto, ) { let net = hat!(tables).peers_net.as_ref().unwrap(); match net.get_idx(source) { @@ -216,7 +216,7 @@ fn register_peer_subscription( face: &mut Arc, res: &mut Arc, sub_info: &SubscriberInfo, - peer: ZenohIdInner, + peer: ZenohIdProto, ) { if !res_hat!(res).peer_subs.contains(&peer) { // Register peer subscription @@ -240,7 +240,7 @@ fn declare_peer_subscription( face: &mut Arc, res: &mut Arc, sub_info: &SubscriberInfo, - peer: ZenohIdInner, + peer: ZenohIdProto, ) { register_peer_subscription(tables, face, res, sub_info, peer); } @@ -407,7 +407,7 @@ fn propagate_forget_sourced_subscription( tables: &Tables, res: &Arc, src_face: Option<&Arc>, - source: &ZenohIdInner, + source: &ZenohIdProto, ) { let net = hat!(tables).peers_net.as_ref().unwrap(); match net.get_idx(source) { @@ -438,7 +438,7 @@ fn propagate_forget_sourced_subscription( } } -fn unregister_peer_subscription(tables: &mut Tables, res: &mut Arc, peer: &ZenohIdInner) { +fn unregister_peer_subscription(tables: &mut Tables, res: &mut Arc, peer: &ZenohIdProto) { res_hat_mut!(res).peer_subs.retain(|sub| sub != peer); if res_hat!(res).peer_subs.is_empty() { @@ -456,7 +456,7 @@ fn undeclare_peer_subscription( tables: &mut Tables, face: Option<&Arc>, res: &mut Arc, - peer: &ZenohIdInner, + peer: &ZenohIdProto, ) { if res_hat!(res).peer_subs.contains(peer) { unregister_peer_subscription(tables, res, peer); @@ -468,7 +468,7 @@ fn forget_peer_subscription( tables: &mut Tables, face: &mut Arc, res: &mut Arc, - peer: &ZenohIdInner, + peer: &ZenohIdProto, ) { undeclare_peer_subscription(tables, Some(face), res, peer); } @@ -554,7 +554,7 @@ fn forget_client_subscription( } } -pub(super) fn pubsub_remove_node(tables: &mut Tables, node: &ZenohIdInner) { +pub(super) fn pubsub_remove_node(tables: &mut Tables, node: &ZenohIdProto) { for mut res in hat!(tables) .peer_subs .iter() @@ -813,7 +813,7 @@ impl HatPubSubTrait for HatCode { tables: &Tables, net: &Network, source: NodeId, - subs: &HashSet, + subs: &HashSet, ) { if net.trees.len() > source as usize { for sub in subs { @@ -924,7 +924,7 @@ impl HatPubSubTrait for HatCode { tables: &Tables, net: &Network, source: usize, - subs: &HashSet, + subs: &HashSet, ) { if net.trees.len() > source { for sub in subs { diff --git a/zenoh/src/net/routing/hat/linkstate_peer/queries.rs b/zenoh/src/net/routing/hat/linkstate_peer/queries.rs index a326386f93..ea893c05b1 100644 --- a/zenoh/src/net/routing/hat/linkstate_peer/queries.rs +++ b/zenoh/src/net/routing/hat/linkstate_peer/queries.rs @@ -26,7 +26,7 @@ use zenoh_protocol::{ include::{Includer, DEFAULT_INCLUDER}, OwnedKeyExpr, }, - WhatAmI, WireExpr, ZenohIdInner, + WhatAmI, WireExpr, ZenohIdProto, }, network::{ declare::{ @@ -208,7 +208,7 @@ fn propagate_sourced_queryable( res: &Arc, qabl_info: &QueryableInfoType, src_face: Option<&mut Arc>, - source: &ZenohIdInner, + source: &ZenohIdProto, ) { let net = hat!(tables).peers_net.as_ref().unwrap(); match net.get_idx(source) { @@ -245,7 +245,7 @@ fn register_peer_queryable( mut face: Option<&mut Arc>, res: &mut Arc, qabl_info: &QueryableInfoType, - peer: ZenohIdInner, + peer: ZenohIdProto, ) { let current_info = res_hat!(res).peer_qabls.get(&peer); if current_info.is_none() || current_info.unwrap() != qabl_info { @@ -270,7 +270,7 @@ fn declare_peer_queryable( face: &mut Arc, res: &mut Arc, qabl_info: &QueryableInfoType, - peer: ZenohIdInner, + peer: ZenohIdProto, ) { let face = Some(face); register_peer_queryable(tables, face, res, qabl_info, peer); @@ -431,7 +431,7 @@ fn propagate_forget_sourced_queryable( tables: &mut Tables, res: &mut Arc, src_face: Option<&Arc>, - source: &ZenohIdInner, + source: &ZenohIdProto, ) { let net = hat!(tables).peers_net.as_ref().unwrap(); match net.get_idx(source) { @@ -462,7 +462,7 @@ fn propagate_forget_sourced_queryable( } } -fn unregister_peer_queryable(tables: &mut Tables, res: &mut Arc, peer: &ZenohIdInner) { +fn unregister_peer_queryable(tables: &mut Tables, res: &mut Arc, peer: &ZenohIdProto) { res_hat_mut!(res).peer_qabls.remove(peer); if res_hat!(res).peer_qabls.is_empty() { @@ -480,7 +480,7 @@ fn undeclare_peer_queryable( tables: &mut Tables, face: Option<&Arc>, res: &mut Arc, - peer: &ZenohIdInner, + peer: &ZenohIdProto, ) { if res_hat!(res).peer_qabls.contains_key(peer) { unregister_peer_queryable(tables, res, peer); @@ -492,7 +492,7 @@ fn forget_peer_queryable( tables: &mut Tables, face: &mut Arc, res: &mut Arc, - peer: &ZenohIdInner, + peer: &ZenohIdProto, ) { undeclare_peer_queryable(tables, Some(face), res, peer); } @@ -584,7 +584,7 @@ fn forget_client_queryable( } } -pub(super) fn queries_remove_node(tables: &mut Tables, node: &ZenohIdInner) { +pub(super) fn queries_remove_node(tables: &mut Tables, node: &ZenohIdProto) { let mut qabls = vec![]; for res in hat!(tables).peer_qabls.iter() { for qabl in res_hat!(res).peer_qabls.keys() { @@ -641,7 +641,7 @@ fn insert_target_for_qabls( tables: &Tables, net: &Network, source: NodeId, - qabls: &HashMap, + qabls: &HashMap, complete: bool, ) { if net.trees.len() > source as usize { diff --git a/zenoh/src/net/routing/hat/mod.rs b/zenoh/src/net/routing/hat/mod.rs index 7f6c749337..b8aa28d5f4 100644 --- a/zenoh/src/net/routing/hat/mod.rs +++ b/zenoh/src/net/routing/hat/mod.rs @@ -22,7 +22,7 @@ use std::{any::Any, collections::HashMap, sync::Arc}; use zenoh_buffers::ZBuf; use zenoh_config::{unwrap_or_default, Config, WhatAmI}; use zenoh_protocol::{ - core::{WireExpr, ZenohIdInner}, + core::{WireExpr, ZenohIdProto}, network::{ declare::{ queryable::ext::QueryableInfoType, subscriber::ext::SubscriberInfo, QueryableId, @@ -55,9 +55,9 @@ zconfigurable! { #[derive(serde::Serialize)] pub(crate) struct Sources { - routers: Vec, - peers: Vec, - clients: Vec, + routers: Vec, + peers: Vec, + clients: Vec, } impl Sources { diff --git a/zenoh/src/net/routing/hat/p2p_peer/gossip.rs b/zenoh/src/net/routing/hat/p2p_peer/gossip.rs index bd76805121..b3216c6b8c 100644 --- a/zenoh/src/net/routing/hat/p2p_peer/gossip.rs +++ b/zenoh/src/net/routing/hat/p2p_peer/gossip.rs @@ -23,7 +23,7 @@ use zenoh_codec::WCodec; use zenoh_link::Locator; use zenoh_protocol::{ common::ZExtBody, - core::{WhatAmI, WhatAmIMatcher, ZenohIdInner}, + core::{WhatAmI, WhatAmIMatcher, ZenohIdProto}, network::{oam, oam::id::OAM_LINKSTATE, NetworkBody, NetworkMessage, Oam}, }; use zenoh_transport::unicast::TransportUnicast; @@ -43,11 +43,11 @@ struct Details { #[derive(Clone)] pub(super) struct Node { - pub(super) zid: ZenohIdInner, + pub(super) zid: ZenohIdProto, pub(super) whatami: Option, pub(super) locators: Option>, pub(super) sn: u64, - pub(super) links: Vec, + pub(super) links: Vec, } impl std::fmt::Debug for Node { @@ -58,8 +58,8 @@ impl std::fmt::Debug for Node { pub(super) struct Link { pub(super) transport: TransportUnicast, - zid: ZenohIdInner, - mappings: VecMap, + zid: ZenohIdProto, + mappings: VecMap, local_mappings: VecMap, } @@ -75,12 +75,12 @@ impl Link { } #[inline] - pub(super) fn set_zid_mapping(&mut self, psid: u64, zid: ZenohIdInner) { + pub(super) fn set_zid_mapping(&mut self, psid: u64, zid: ZenohIdProto) { self.mappings.insert(psid.try_into().unwrap(), zid); } #[inline] - pub(super) fn get_zid(&self, psid: &u64) -> Option<&ZenohIdInner> { + pub(super) fn get_zid(&self, psid: &u64) -> Option<&ZenohIdProto> { self.mappings.get((*psid).try_into().unwrap()) } @@ -106,7 +106,7 @@ pub(super) struct Network { impl Network { pub(super) fn new( name: String, - zid: ZenohIdInner, + zid: ZenohIdProto, runtime: Runtime, router_peers_failover_brokering: bool, gossip: bool, @@ -144,14 +144,14 @@ impl Network { // } #[inline] - pub(super) fn get_idx(&self, zid: &ZenohIdInner) -> Option { + pub(super) fn get_idx(&self, zid: &ZenohIdProto) -> Option { self.graph .node_indices() .find(|idx| self.graph[*idx].zid == *zid) } #[inline] - pub(super) fn get_link_from_zid(&self, zid: &ZenohIdInner) -> Option<&Link> { + pub(super) fn get_link_from_zid(&self, zid: &ZenohIdProto) -> Option<&Link> { self.links.values().find(|link| link.zid == *zid) } @@ -271,7 +271,7 @@ impl Network { })) } - pub(super) fn link_states(&mut self, link_states: Vec, src: ZenohIdInner) { + pub(super) fn link_states(&mut self, link_states: Vec, src: ZenohIdProto) { tracing::trace!("{} Received from {} raw: {:?}", self.name, src, link_states); let strong_runtime = self.runtime.upgrade().unwrap(); @@ -333,7 +333,7 @@ impl Network { let link_states = link_states .into_iter() .map(|(zid, wai, locs, sn, links)| { - let links: Vec = links + let links: Vec = links .iter() .filter_map(|l| { if let Some(zid) = src_link.get_zid(l) { @@ -551,7 +551,7 @@ impl Network { free_index } - pub(super) fn remove_link(&mut self, zid: &ZenohIdInner) -> Vec<(NodeIndex, Node)> { + pub(super) fn remove_link(&mut self, zid: &ZenohIdProto) -> Vec<(NodeIndex, Node)> { tracing::trace!("{} remove_link {}", self.name, zid); self.links.retain(|_, link| link.zid != *zid); self.graph[self.idx].links.retain(|link| *link != *zid); diff --git a/zenoh/src/net/routing/hat/router/mod.rs b/zenoh/src/net/routing/hat/router/mod.rs index e2d33e79b9..46dfe6f058 100644 --- a/zenoh/src/net/routing/hat/router/mod.rs +++ b/zenoh/src/net/routing/hat/router/mod.rs @@ -28,7 +28,7 @@ use std::{ use zenoh_config::{unwrap_or_default, ModeDependent, WhatAmI, WhatAmIMatcher}; use zenoh_protocol::{ common::ZExtBody, - core::ZenohIdInner, + core::ZenohIdProto, network::{ declare::{queryable::ext::QueryableInfoType, QueryableId, SubscriberId}, interest::InterestId, @@ -121,7 +121,7 @@ struct HatTables { peer_qabls: HashSet>, routers_net: Option, peers_net: Option, - shared_nodes: Vec, + shared_nodes: Vec, routers_trees_task: Option, peers_trees_task: Option, router_peers_failover_brokering: bool, @@ -183,7 +183,7 @@ impl HatTables { } #[inline] - fn get_router_links(&self, peer: ZenohIdInner) -> impl Iterator + '_ { + fn get_router_links(&self, peer: ZenohIdProto) -> impl Iterator + '_ { self.peers_net .as_ref() .unwrap() @@ -201,14 +201,14 @@ impl HatTables { #[inline] fn elect_router<'a>( &'a self, - self_zid: &'a ZenohIdInner, + self_zid: &'a ZenohIdProto, key_expr: &str, - mut routers: impl Iterator, - ) -> &'a ZenohIdInner { + mut routers: impl Iterator, + ) -> &'a ZenohIdProto { match routers.next() { None => self_zid, Some(router) => { - let hash = |r: &ZenohIdInner| { + let hash = |r: &ZenohIdProto| { let mut hasher = DefaultHasher::new(); for b in key_expr.as_bytes() { hasher.write_u8(*b); @@ -233,13 +233,13 @@ impl HatTables { } #[inline] - fn failover_brokering_to(source_links: &[ZenohIdInner], dest: ZenohIdInner) -> bool { + fn failover_brokering_to(source_links: &[ZenohIdProto], dest: ZenohIdProto) -> bool { // if source_links is empty then gossip is probably disabled in source peer !source_links.is_empty() && !source_links.contains(&dest) } #[inline] - fn failover_brokering(&self, peer1: ZenohIdInner, peer2: ZenohIdInner) -> bool { + fn failover_brokering(&self, peer1: ZenohIdProto, peer2: ZenohIdProto) -> bool { self.router_peers_failover_brokering && self .peers_net @@ -762,10 +762,10 @@ impl HatBaseTrait for HatCode { } struct HatContext { - router_subs: HashSet, - peer_subs: HashSet, - router_qabls: HashMap, - peer_qabls: HashMap, + router_subs: HashSet, + peer_subs: HashSet, + router_qabls: HashMap, + peer_qabls: HashMap, } impl HatContext { @@ -805,7 +805,7 @@ impl HatFace { } } -fn get_router(tables: &Tables, face: &Arc, nodeid: NodeId) -> Option { +fn get_router(tables: &Tables, face: &Arc, nodeid: NodeId) -> Option { match hat!(tables) .routers_net .as_ref() @@ -832,7 +832,7 @@ fn get_router(tables: &Tables, face: &Arc, nodeid: NodeId) -> Option< } } -fn get_peer(tables: &Tables, face: &Arc, nodeid: NodeId) -> Option { +fn get_peer(tables: &Tables, face: &Arc, nodeid: NodeId) -> Option { match hat!(tables) .peers_net .as_ref() diff --git a/zenoh/src/net/routing/hat/router/network.rs b/zenoh/src/net/routing/hat/router/network.rs index fb04fe6f86..151957d19a 100644 --- a/zenoh/src/net/routing/hat/router/network.rs +++ b/zenoh/src/net/routing/hat/router/network.rs @@ -27,7 +27,7 @@ use zenoh_codec::WCodec; use zenoh_link::Locator; use zenoh_protocol::{ common::ZExtBody, - core::{WhatAmI, WhatAmIMatcher, ZenohIdInner}, + core::{WhatAmI, WhatAmIMatcher, ZenohIdProto}, network::{oam, oam::id::OAM_LINKSTATE, NetworkBody, NetworkMessage, Oam}, }; use zenoh_transport::unicast::TransportUnicast; @@ -48,11 +48,11 @@ struct Details { #[derive(Clone)] pub(super) struct Node { - pub(super) zid: ZenohIdInner, + pub(super) zid: ZenohIdProto, pub(super) whatami: Option, pub(super) locators: Option>, pub(super) sn: u64, - pub(super) links: Vec, + pub(super) links: Vec, } impl std::fmt::Debug for Node { @@ -63,8 +63,8 @@ impl std::fmt::Debug for Node { pub(super) struct Link { pub(super) transport: TransportUnicast, - zid: ZenohIdInner, - mappings: VecMap, + zid: ZenohIdProto, + mappings: VecMap, local_mappings: VecMap, } @@ -80,12 +80,12 @@ impl Link { } #[inline] - pub(super) fn set_zid_mapping(&mut self, psid: u64, zid: ZenohIdInner) { + pub(super) fn set_zid_mapping(&mut self, psid: u64, zid: ZenohIdProto) { self.mappings.insert(psid.try_into().unwrap(), zid); } #[inline] - pub(super) fn get_zid(&self, psid: &u64) -> Option<&ZenohIdInner> { + pub(super) fn get_zid(&self, psid: &u64) -> Option<&ZenohIdProto> { self.mappings.get((*psid).try_into().unwrap()) } @@ -132,7 +132,7 @@ impl Network { #[allow(clippy::too_many_arguments)] pub(super) fn new( name: String, - zid: ZenohIdInner, + zid: ZenohIdProto, runtime: Runtime, full_linkstate: bool, router_peers_failover_brokering: bool, @@ -177,12 +177,12 @@ impl Network { } #[inline] - pub(super) fn get_node(&self, zid: &ZenohIdInner) -> Option<&Node> { + pub(super) fn get_node(&self, zid: &ZenohIdProto) -> Option<&Node> { self.graph.node_weights().find(|weight| weight.zid == *zid) } #[inline] - pub(super) fn get_idx(&self, zid: &ZenohIdInner) -> Option { + pub(super) fn get_idx(&self, zid: &ZenohIdProto) -> Option { self.graph .node_indices() .find(|idx| self.graph[*idx].zid == *zid) @@ -194,7 +194,7 @@ impl Network { } #[inline] - pub(super) fn get_link_from_zid(&self, zid: &ZenohIdInner) -> Option<&Link> { + pub(super) fn get_link_from_zid(&self, zid: &ZenohIdProto) -> Option<&Link> { self.links.values().find(|link| link.zid == *zid) } @@ -352,7 +352,7 @@ impl Network { pub(super) fn link_states( &mut self, link_states: Vec, - src: ZenohIdInner, + src: ZenohIdProto, ) -> Changes { tracing::trace!("{} Received from {} raw: {:?}", self.name, src, link_states); @@ -417,7 +417,7 @@ impl Network { let link_states = link_states .into_iter() .map(|(zid, wai, locs, sn, links)| { - let links: Vec = links + let links: Vec = links .iter() .filter_map(|l| { if let Some(zid) = src_link.get_zid(l) { @@ -567,7 +567,7 @@ impl Network { } }, ) - .collect::, NodeIndex, bool)>>(); + .collect::, NodeIndex, bool)>>(); // Add/remove edges from graph let mut reintroduced_nodes = vec![]; @@ -619,7 +619,7 @@ impl Network { let link_states = link_states .into_iter() .filter(|ls| !removed.iter().any(|(idx, _)| idx == &ls.1)) - .collect::, NodeIndex, bool)>>(); + .collect::, NodeIndex, bool)>>(); if !self.autoconnect.is_empty() { // Connect discovered peers @@ -658,8 +658,8 @@ impl Network { #[allow(clippy::type_complexity)] // This is only used here if !link_states.is_empty() { let (new_idxs, updated_idxs): ( - Vec<(Vec, NodeIndex, bool)>, - Vec<(Vec, NodeIndex, bool)>, + Vec<(Vec, NodeIndex, bool)>, + Vec<(Vec, NodeIndex, bool)>, ) = link_states.into_iter().partition(|(_, _, new)| *new); let new_idxs = new_idxs .into_iter() @@ -823,7 +823,7 @@ impl Network { free_index } - pub(super) fn remove_link(&mut self, zid: &ZenohIdInner) -> Vec<(NodeIndex, Node)> { + pub(super) fn remove_link(&mut self, zid: &ZenohIdProto) -> Vec<(NodeIndex, Node)> { tracing::trace!("{} remove_link {}", self.name, zid); self.links.retain(|_, link| link.zid != *zid); self.graph[self.idx].links.retain(|link| *link != *zid); @@ -1003,7 +1003,7 @@ impl Network { } #[inline] - pub(super) fn get_links(&self, node: ZenohIdInner) -> &[ZenohIdInner] { + pub(super) fn get_links(&self, node: ZenohIdProto) -> &[ZenohIdProto] { self.get_node(&node) .map(|node| &node.links[..]) .unwrap_or_default() @@ -1011,7 +1011,7 @@ impl Network { } #[inline] -pub(super) fn shared_nodes(net1: &Network, net2: &Network) -> Vec { +pub(super) fn shared_nodes(net1: &Network, net2: &Network) -> Vec { net1.graph .node_references() .filter_map(|(_, node1)| { diff --git a/zenoh/src/net/routing/hat/router/pubsub.rs b/zenoh/src/net/routing/hat/router/pubsub.rs index 2e4fc5b936..dba4d58e85 100644 --- a/zenoh/src/net/routing/hat/router/pubsub.rs +++ b/zenoh/src/net/routing/hat/router/pubsub.rs @@ -19,7 +19,7 @@ use std::{ use petgraph::graph::NodeIndex; use zenoh_protocol::{ - core::{key_expr::OwnedKeyExpr, Reliability, WhatAmI, ZenohIdInner}, + core::{key_expr::OwnedKeyExpr, Reliability, WhatAmI, ZenohIdProto}, network::{ declare::{ common::ext::WireExprType, ext, subscriber::ext::SubscriberInfo, Declare, DeclareBody, @@ -176,7 +176,7 @@ fn propagate_sourced_subscription( res: &Arc, sub_info: &SubscriberInfo, src_face: Option<&Arc>, - source: &ZenohIdInner, + source: &ZenohIdProto, net_type: WhatAmI, ) { let net = hat!(tables).get_net(net_type).unwrap(); @@ -214,7 +214,7 @@ fn register_router_subscription( face: &mut Arc, res: &mut Arc, sub_info: &SubscriberInfo, - router: ZenohIdInner, + router: ZenohIdProto, ) { if !res_hat!(res).router_subs.contains(&router) { // Register router subscription @@ -240,7 +240,7 @@ fn declare_router_subscription( face: &mut Arc, res: &mut Arc, sub_info: &SubscriberInfo, - router: ZenohIdInner, + router: ZenohIdProto, ) { register_router_subscription(tables, face, res, sub_info, router); } @@ -250,7 +250,7 @@ fn register_peer_subscription( face: &mut Arc, res: &mut Arc, sub_info: &SubscriberInfo, - peer: ZenohIdInner, + peer: ZenohIdProto, ) { if !res_hat!(res).peer_subs.contains(&peer) { // Register peer subscription @@ -269,7 +269,7 @@ fn declare_peer_subscription( face: &mut Arc, res: &mut Arc, sub_info: &SubscriberInfo, - peer: ZenohIdInner, + peer: ZenohIdProto, ) { register_peer_subscription(tables, face, res, sub_info, peer); let propa_sub_info = *sub_info; @@ -491,7 +491,7 @@ fn propagate_forget_sourced_subscription( tables: &Tables, res: &Arc, src_face: Option<&Arc>, - source: &ZenohIdInner, + source: &ZenohIdProto, net_type: WhatAmI, ) { let net = hat!(tables).get_net(net_type).unwrap(); @@ -526,7 +526,7 @@ fn propagate_forget_sourced_subscription( fn unregister_router_subscription( tables: &mut Tables, res: &mut Arc, - router: &ZenohIdInner, + router: &ZenohIdProto, ) { res_hat_mut!(res).router_subs.retain(|sub| sub != router); @@ -548,7 +548,7 @@ fn undeclare_router_subscription( tables: &mut Tables, face: Option<&Arc>, res: &mut Arc, - router: &ZenohIdInner, + router: &ZenohIdProto, ) { if res_hat!(res).router_subs.contains(router) { unregister_router_subscription(tables, res, router); @@ -560,12 +560,12 @@ fn forget_router_subscription( tables: &mut Tables, face: &mut Arc, res: &mut Arc, - router: &ZenohIdInner, + router: &ZenohIdProto, ) { undeclare_router_subscription(tables, Some(face), res, router); } -fn unregister_peer_subscription(tables: &mut Tables, res: &mut Arc, peer: &ZenohIdInner) { +fn unregister_peer_subscription(tables: &mut Tables, res: &mut Arc, peer: &ZenohIdProto) { res_hat_mut!(res).peer_subs.retain(|sub| sub != peer); if res_hat!(res).peer_subs.is_empty() { @@ -579,7 +579,7 @@ fn undeclare_peer_subscription( tables: &mut Tables, face: Option<&Arc>, res: &mut Arc, - peer: &ZenohIdInner, + peer: &ZenohIdProto, ) { if res_hat!(res).peer_subs.contains(peer) { unregister_peer_subscription(tables, res, peer); @@ -591,7 +591,7 @@ fn forget_peer_subscription( tables: &mut Tables, face: &mut Arc, res: &mut Arc, - peer: &ZenohIdInner, + peer: &ZenohIdProto, ) { undeclare_peer_subscription(tables, Some(face), res, peer); let client_subs = res.session_ctxs.values().any(|ctx| ctx.subs.is_some()); @@ -688,7 +688,7 @@ fn forget_client_subscription( } } -pub(super) fn pubsub_remove_node(tables: &mut Tables, node: &ZenohIdInner, net_type: WhatAmI) { +pub(super) fn pubsub_remove_node(tables: &mut Tables, node: &ZenohIdProto, net_type: WhatAmI) { match net_type { WhatAmI::Router => { for mut res in hat!(tables) @@ -777,8 +777,8 @@ pub(super) fn pubsub_tree_change( pub(super) fn pubsub_linkstate_change( tables: &mut Tables, - zid: &ZenohIdInner, - links: &[ZenohIdInner], + zid: &ZenohIdProto, + links: &[ZenohIdProto], ) { if let Some(src_face) = tables.get_face(zid).cloned() { if hat!(tables).router_peers_failover_brokering && src_face.whatami == WhatAmI::Peer { @@ -1130,7 +1130,7 @@ impl HatPubSubTrait for HatCode { tables: &Tables, net: &Network, source: NodeId, - subs: &HashSet, + subs: &HashSet, ) { if net.trees.len() > source as usize { for sub in subs { @@ -1263,7 +1263,7 @@ impl HatPubSubTrait for HatCode { tables: &Tables, net: &Network, source: usize, - subs: &HashSet, + subs: &HashSet, ) { if net.trees.len() > source { for sub in subs { diff --git a/zenoh/src/net/routing/hat/router/queries.rs b/zenoh/src/net/routing/hat/router/queries.rs index e00072adeb..217d74955f 100644 --- a/zenoh/src/net/routing/hat/router/queries.rs +++ b/zenoh/src/net/routing/hat/router/queries.rs @@ -26,7 +26,7 @@ use zenoh_protocol::{ include::{Includer, DEFAULT_INCLUDER}, OwnedKeyExpr, }, - WhatAmI, WireExpr, ZenohIdInner, + WhatAmI, WireExpr, ZenohIdProto, }, network::{ declare::{ @@ -286,7 +286,7 @@ fn propagate_sourced_queryable( res: &Arc, qabl_info: &QueryableInfoType, src_face: Option<&mut Arc>, - source: &ZenohIdInner, + source: &ZenohIdProto, net_type: WhatAmI, ) { let net = hat!(tables).get_net(net_type).unwrap(); @@ -324,7 +324,7 @@ fn register_router_queryable( mut face: Option<&mut Arc>, res: &mut Arc, qabl_info: &QueryableInfoType, - router: ZenohIdInner, + router: ZenohIdProto, ) { let current_info = res_hat!(res).router_qabls.get(&router); if current_info.is_none() || current_info.unwrap() != qabl_info { @@ -362,7 +362,7 @@ fn declare_router_queryable( face: &mut Arc, res: &mut Arc, qabl_info: &QueryableInfoType, - router: ZenohIdInner, + router: ZenohIdProto, ) { register_router_queryable(tables, Some(face), res, qabl_info, router); } @@ -372,7 +372,7 @@ fn register_peer_queryable( face: Option<&mut Arc>, res: &mut Arc, qabl_info: &QueryableInfoType, - peer: ZenohIdInner, + peer: ZenohIdProto, ) { let current_info = res_hat!(res).peer_qabls.get(&peer); if current_info.is_none() || current_info.unwrap() != qabl_info { @@ -392,7 +392,7 @@ fn declare_peer_queryable( face: &mut Arc, res: &mut Arc, qabl_info: &QueryableInfoType, - peer: ZenohIdInner, + peer: ZenohIdProto, ) { let mut face = Some(face); register_peer_queryable(tables, face.as_deref_mut(), res, qabl_info, peer); @@ -608,7 +608,7 @@ fn propagate_forget_sourced_queryable( tables: &mut Tables, res: &mut Arc, src_face: Option<&Arc>, - source: &ZenohIdInner, + source: &ZenohIdProto, net_type: WhatAmI, ) { let net = hat!(tables).get_net(net_type).unwrap(); @@ -643,7 +643,7 @@ fn propagate_forget_sourced_queryable( fn unregister_router_queryable( tables: &mut Tables, res: &mut Arc, - router: &ZenohIdInner, + router: &ZenohIdProto, ) { res_hat_mut!(res).router_qabls.remove(router); @@ -665,7 +665,7 @@ fn undeclare_router_queryable( tables: &mut Tables, face: Option<&Arc>, res: &mut Arc, - router: &ZenohIdInner, + router: &ZenohIdProto, ) { if res_hat!(res).router_qabls.contains_key(router) { unregister_router_queryable(tables, res, router); @@ -677,12 +677,12 @@ fn forget_router_queryable( tables: &mut Tables, face: &mut Arc, res: &mut Arc, - router: &ZenohIdInner, + router: &ZenohIdProto, ) { undeclare_router_queryable(tables, Some(face), res, router); } -fn unregister_peer_queryable(tables: &mut Tables, res: &mut Arc, peer: &ZenohIdInner) { +fn unregister_peer_queryable(tables: &mut Tables, res: &mut Arc, peer: &ZenohIdProto) { res_hat_mut!(res).peer_qabls.remove(peer); if res_hat!(res).peer_qabls.is_empty() { @@ -696,7 +696,7 @@ fn undeclare_peer_queryable( tables: &mut Tables, face: Option<&Arc>, res: &mut Arc, - peer: &ZenohIdInner, + peer: &ZenohIdProto, ) { if res_hat!(res).peer_qabls.contains_key(peer) { unregister_peer_queryable(tables, res, peer); @@ -708,7 +708,7 @@ fn forget_peer_queryable( tables: &mut Tables, face: &mut Arc, res: &mut Arc, - peer: &ZenohIdInner, + peer: &ZenohIdProto, ) { undeclare_peer_queryable(tables, Some(face), res, peer); @@ -814,7 +814,7 @@ fn forget_client_queryable( } } -pub(super) fn queries_remove_node(tables: &mut Tables, node: &ZenohIdInner, net_type: WhatAmI) { +pub(super) fn queries_remove_node(tables: &mut Tables, node: &ZenohIdProto, net_type: WhatAmI) { match net_type { WhatAmI::Router => { let mut qabls = vec![]; @@ -863,8 +863,8 @@ pub(super) fn queries_remove_node(tables: &mut Tables, node: &ZenohIdInner, net_ pub(super) fn queries_linkstate_change( tables: &mut Tables, - zid: &ZenohIdInner, - links: &[ZenohIdInner], + zid: &ZenohIdProto, + links: &[ZenohIdProto], ) { if let Some(src_face) = tables.get_face(zid) { if hat!(tables).router_peers_failover_brokering && src_face.whatami == WhatAmI::Peer { @@ -998,7 +998,7 @@ fn insert_target_for_qabls( tables: &Tables, net: &Network, source: NodeId, - qabls: &HashMap, + qabls: &HashMap, complete: bool, ) { if net.trees.len() > source as usize { diff --git a/zenoh/src/net/routing/interceptor/access_control.rs b/zenoh/src/net/routing/interceptor/access_control.rs index 1c8dac170b..b237ac1b78 100644 --- a/zenoh/src/net/routing/interceptor/access_control.rs +++ b/zenoh/src/net/routing/interceptor/access_control.rs @@ -22,7 +22,7 @@ use std::{any::Any, sync::Arc}; use zenoh_config::{AclConfig, Action, InterceptorFlow, Permission, Subject}; use zenoh_protocol::{ - core::ZenohIdInner, + core::ZenohIdProto, network::{Declare, DeclareBody, NetworkBody, NetworkMessage, Push, Request}, zenoh::{PushBody, RequestBody}, }; @@ -45,12 +45,12 @@ pub struct Interface { struct EgressAclEnforcer { policy_enforcer: Arc, interface_list: Vec, - zid: ZenohIdInner, + zid: ZenohIdProto, } struct IngressAclEnforcer { policy_enforcer: Arc, interface_list: Vec, - zid: ZenohIdInner, + zid: ZenohIdProto, } pub(crate) fn acl_interceptor_factories( @@ -284,7 +284,7 @@ impl InterceptorTrait for EgressAclEnforcer { pub trait AclActionMethods { fn policy_enforcer(&self) -> Arc; fn interface_list(&self) -> Vec; - fn zid(&self) -> ZenohIdInner; + fn zid(&self) -> ZenohIdProto; fn flow(&self) -> InterceptorFlow; fn action(&self, action: Action, log_msg: &str, key_expr: &str) -> Permission { let policy_enforcer = self.policy_enforcer(); @@ -342,7 +342,7 @@ impl AclActionMethods for EgressAclEnforcer { self.interface_list.clone() } - fn zid(&self) -> ZenohIdInner { + fn zid(&self) -> ZenohIdProto { self.zid } fn flow(&self) -> InterceptorFlow { @@ -359,7 +359,7 @@ impl AclActionMethods for IngressAclEnforcer { self.interface_list.clone() } - fn zid(&self) -> ZenohIdInner { + fn zid(&self) -> ZenohIdProto { self.zid } fn flow(&self) -> InterceptorFlow { diff --git a/zenoh/src/net/routing/router.rs b/zenoh/src/net/routing/router.rs index 08668253e2..d11ab24b5b 100644 --- a/zenoh/src/net/routing/router.rs +++ b/zenoh/src/net/routing/router.rs @@ -18,7 +18,7 @@ use std::{ use uhlc::HLC; use zenoh_config::Config; -use zenoh_protocol::core::{WhatAmI, ZenohIdInner}; +use zenoh_protocol::core::{WhatAmI, ZenohIdProto}; // use zenoh_collections::Timer; use zenoh_result::ZResult; use zenoh_transport::{multicast::TransportMulticast, unicast::TransportUnicast, TransportPeer}; @@ -45,7 +45,7 @@ pub struct Router { impl Router { pub fn new( - zid: ZenohIdInner, + zid: ZenohIdProto, whatami: WhatAmI, hlc: Option>, config: &Config, @@ -176,7 +176,7 @@ impl Router { let mux = Arc::new(McastMux::new(transport.clone(), interceptor)); let face = FaceState::new( fid, - ZenohIdInner::from_str("1").unwrap(), + ZenohIdProto::from_str("1").unwrap(), WhatAmI::Peer, #[cfg(feature = "stats")] None, diff --git a/zenoh/src/net/runtime/orchestrator.rs b/zenoh/src/net/runtime/orchestrator.rs index c75e9ccc5a..73a0355199 100644 --- a/zenoh/src/net/runtime/orchestrator.rs +++ b/zenoh/src/net/runtime/orchestrator.rs @@ -32,8 +32,8 @@ use zenoh_config::{ }; use zenoh_link::{Locator, LocatorInspector}; use zenoh_protocol::{ - core::{whatami::WhatAmIMatcher, EndPoint, WhatAmI, ZenohIdInner}, - scouting::{HelloInner, Scout, ScoutingBody, ScoutingMessage}, + core::{whatami::WhatAmIMatcher, EndPoint, WhatAmI, ZenohIdProto}, + scouting::{HelloProto, Scout, ScoutingBody, ScoutingMessage}, }; use zenoh_result::{bail, zerror, ZResult}; @@ -53,7 +53,7 @@ pub enum Loop { #[derive(Default, Debug)] pub(crate) struct PeerConnector { - zid: Option, + zid: Option, terminated: bool, } @@ -74,7 +74,7 @@ impl StartConditions { peer_connectors.len() - 1 } - pub(crate) async fn add_peer_connector_zid(&self, zid: ZenohIdInner) { + pub(crate) async fn add_peer_connector_zid(&self, zid: ZenohIdProto) { let mut peer_connectors = self.peer_connectors.lock().await; if !peer_connectors.iter().any(|pc| pc.zid == Some(zid)) { peer_connectors.push(PeerConnector { @@ -84,7 +84,7 @@ impl StartConditions { } } - pub(crate) async fn set_peer_connector_zid(&self, idx: usize, zid: ZenohIdInner) { + pub(crate) async fn set_peer_connector_zid(&self, idx: usize, zid: ZenohIdProto) { let mut peer_connectors = self.peer_connectors.lock().await; if let Some(peer_connector) = peer_connectors.get_mut(idx) { peer_connector.zid = Some(zid); @@ -101,7 +101,7 @@ impl StartConditions { } } - pub(crate) async fn terminate_peer_connector_zid(&self, zid: ZenohIdInner) { + pub(crate) async fn terminate_peer_connector_zid(&self, zid: ZenohIdProto) { let mut peer_connectors = self.peer_connectors.lock().await; if let Some(peer_connector) = peer_connectors.iter_mut().find(|pc| pc.zid == Some(zid)) { peer_connector.terminated = true; @@ -777,7 +777,7 @@ impl Runtime { } } - async fn peer_connector_retry(&self, peer: EndPoint) -> ZResult { + async fn peer_connector_retry(&self, peer: EndPoint) -> ZResult { let retry_config = self.get_connect_retry_config(&peer); let mut period = retry_config.period(); let cancellation_token = self.get_cancellation_token(); @@ -829,7 +829,7 @@ impl Runtime { mcast_addr: &SocketAddr, f: F, ) where - F: Fn(HelloInner) -> Fut + std::marker::Send + std::marker::Sync + Clone, + F: Fn(HelloProto) -> Fut + std::marker::Send + std::marker::Sync + Clone, Fut: Future + std::marker::Send, Self: Sized, { @@ -920,7 +920,7 @@ impl Runtime { } #[must_use] - async fn connect(&self, zid: &ZenohIdInner, locators: &[Locator]) -> bool { + async fn connect(&self, zid: &ZenohIdProto, locators: &[Locator]) -> bool { const ERR: &str = "Unable to connect to newly scouted peer "; let inspector = LocatorInspector::default(); @@ -981,7 +981,7 @@ impl Runtime { false } - pub async fn connect_peer(&self, zid: &ZenohIdInner, locators: &[Locator]) { + pub async fn connect_peer(&self, zid: &ZenohIdProto, locators: &[Locator]) { let manager = self.manager(); if zid != &manager.zid() { let has_unicast = manager.get_transport_unicast(zid).await.is_some(); @@ -1104,7 +1104,7 @@ impl Runtime { let codec = Zenoh080::new(); let zid = self.manager().zid(); - let hello: ScoutingMessage = HelloInner { + let hello: ScoutingMessage = HelloProto { version: zenoh_protocol::VERSION, whatami: self.whatami(), zid, diff --git a/zenoh/src/net/tests/tables.rs b/zenoh/src/net/tests/tables.rs index 3507758f15..de0b691b04 100644 --- a/zenoh/src/net/tests/tables.rs +++ b/zenoh/src/net/tests/tables.rs @@ -22,7 +22,7 @@ use zenoh_config::Config; use zenoh_core::zlock; use zenoh_protocol::{ core::{ - key_expr::keyexpr, Encoding, ExprId, Reliability, WhatAmI, WireExpr, ZenohIdInner, + key_expr::keyexpr, Encoding, ExprId, Reliability, WhatAmI, WireExpr, ZenohIdProto, EMPTY_EXPR_ID, }, network::{ @@ -44,7 +44,7 @@ use crate::net::{ fn base_test() { let config = Config::default(); let router = Router::new( - ZenohIdInner::try_from([1]).unwrap(), + ZenohIdProto::try_from([1]).unwrap(), WhatAmI::Client, Some(Arc::new(HLC::default())), &config, @@ -140,7 +140,7 @@ fn match_test() { let config = Config::default(); let router = Router::new( - ZenohIdInner::try_from([1]).unwrap(), + ZenohIdProto::try_from([1]).unwrap(), WhatAmI::Client, Some(Arc::new(HLC::default())), &config, @@ -180,7 +180,7 @@ fn match_test() { fn multisub_test() { let config = Config::default(); let router = Router::new( - ZenohIdInner::try_from([1]).unwrap(), + ZenohIdProto::try_from([1]).unwrap(), WhatAmI::Client, Some(Arc::new(HLC::default())), &config, @@ -249,7 +249,7 @@ fn multisub_test() { async fn clean_test() { let config = Config::default(); let router = Router::new( - ZenohIdInner::try_from([1]).unwrap(), + ZenohIdProto::try_from([1]).unwrap(), WhatAmI::Client, Some(Arc::new(HLC::default())), &config, @@ -569,7 +569,7 @@ impl EPrimitives for ClientPrimitives { fn client_test() { let config = Config::default(); let router = Router::new( - ZenohIdInner::try_from([1]).unwrap(), + ZenohIdProto::try_from([1]).unwrap(), WhatAmI::Client, Some(Arc::new(HLC::default())), &config,