Skip to content

Commit

Permalink
Merge pull request #1138 from eclipse-zenoh/option_replier_id
Browse files Browse the repository at this point in the history
replier_id() returns Option<ZenohId>
  • Loading branch information
milyin authored Jun 14, 2024
2 parents 2293649 + 5e9c725 commit 2a43a1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions zenoh/src/api/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl From<Value> for ReplyError {
#[derive(Clone, Debug)]
pub struct Reply {
pub(crate) result: Result<Sample, ReplyError>,
pub(crate) replier_id: ZenohIdProto,
pub(crate) replier_id: Option<ZenohIdProto>,
}

impl Reply {
Expand All @@ -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<ZenohId> {
self.replier_id.map(Into::into)
}
}

Expand Down
10 changes: 3 additions & 7 deletions zenoh/src/api/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ impl Session {
}
(query.callback)(Reply {
result: Err(Value::from("Timeout").into()),
replier_id: zid.into(),
replier_id: Some(zid.into()),
});
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2a43a1d

Please sign in to comment.