Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replier_id() returns Option<ZenohId> #1138

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading