Skip to content

Commit

Permalink
feat: add tuple implementation for IntoHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfo committed Sep 11, 2024
1 parent acab2bf commit 9ff1756
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions zenoh/src/api/handlers/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ where
}
}

impl<'a, T, F, H> IntoHandler<'a, T> for (F, H)
where
F: Fn(T) + Send + Sync + 'a,
{
type Handler = H;

fn into_handler(self) -> (Callback<'a, T>, Self::Handler) {
(Dyn::from(self.0), self.1)
}
}

impl<'a, T, H> IntoHandler<'a, T> for (Callback<'static, T>, H) {
type Handler = H;

fn into_handler(self) -> (Callback<'a, T>, Self::Handler) {
self
}
}

impl<T: Send + 'static> IntoHandler<'static, T> for (flume::Sender<T>, flume::Receiver<T>) {
type Handler = flume::Receiver<T>;

Expand Down

0 comments on commit 9ff1756

Please sign in to comment.