Skip to content

Commit d5ab0db

Browse files
Add matching listener handler getters (#2059)
* Add matching listener handler getters * derive debug for MatchingListener
1 parent 5d4beac commit d5ab0db

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

zenoh/src/api/matching.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ impl fmt::Debug for MatchingListenerState {
116116
}
117117
}
118118

119+
#[derive(Debug)]
119120
pub(crate) struct MatchingListenerInner {
120121
pub(crate) session: WeakSession,
121122
pub(crate) matching_listeners: Arc<Mutex<HashSet<Id>>>,
@@ -147,6 +148,7 @@ pub(crate) struct MatchingListenerInner {
147148
/// }
148149
/// # }
149150
/// ```
151+
#[derive(Debug)]
150152
pub struct MatchingListener<Handler> {
151153
pub(crate) inner: MatchingListenerInner,
152154
pub(crate) handler: Handler,
@@ -183,6 +185,20 @@ impl<Handler> MatchingListener<Handler> {
183185
.undeclare_matches_listener_inner(self.inner.id)
184186
}
185187

188+
/// Returns a reference to this matching listener's handler.
189+
/// An handler is anything that implements [`crate::handlers::IntoHandler`].
190+
/// The default handler is [`crate::handlers::DefaultHandler`].
191+
pub fn handler(&self) -> &Handler {
192+
&self.handler
193+
}
194+
195+
/// Returns a mutable reference to this matching listener's handler.
196+
/// An handler is anything that implements [`crate::handlers::IntoHandler`].
197+
/// The default handler is [`crate::handlers::DefaultHandler`].
198+
pub fn handler_mut(&mut self) -> &mut Handler {
199+
&mut self.handler
200+
}
201+
186202
#[zenoh_macros::internal]
187203
pub fn set_background(&mut self, background: bool) {
188204
self.inner.undeclare_on_drop = !background;

0 commit comments

Comments
 (0)