diff --git a/zenoh/src/api/query.rs b/zenoh/src/api/query.rs index fc5bb2e5d7..c294839f90 100644 --- a/zenoh/src/api/query.rs +++ b/zenoh/src/api/query.rs @@ -118,7 +118,7 @@ impl From for ReplyError { #[derive(Clone, Debug)] pub struct Reply { pub(crate) result: Result, - pub(crate) replier_id: ZenohIdProto, + pub(crate) replier_id: Option, } impl Reply { @@ -138,8 +138,8 @@ impl Reply { } /// Gets the id of the zenoh instance that answered this Reply. - pub fn replier_id(&self) -> ZenohId { - self.replier_id.into() + pub fn replier_id(&self) -> Option { + self.replier_id.map(Into::into) } } diff --git a/zenoh/src/api/session.rs b/zenoh/src/api/session.rs index 5c5d66e8bd..c1d7290e72 100644 --- a/zenoh/src/api/session.rs +++ b/zenoh/src/api/session.rs @@ -1702,7 +1702,7 @@ impl Session { } (query.callback)(Reply { result: Err(Value::from("Timeout").into()), - replier_id: zid.into(), + replier_id: Some(zid.into()), }); } } @@ -2194,12 +2194,8 @@ impl Primitives for Session { payload: e.payload.into(), encoding: e.encoding.into(), }; - let replier_id = match e.ext_sinfo { - Some(info) => info.id.zid, - None => zenoh_protocol::core::ZenohIdProto::rand(), - }; let new_reply = Reply { - replier_id, + replier_id: e.ext_sinfo.map(|info| info.id.zid), result: Err(value.into()), }; callback(new_reply); @@ -2308,7 +2304,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::ZenohIdProto::rand(), // TODO + replier_id: None, }; let callback = match query.reception_mode {