viz_core/handler/
around.rs1use crate::{Handler, Result};
2
3pub type Next<I, H> = (I, H);
5
6#[derive(Debug, Clone)]
8pub struct Around<H, F> {
9 h: H,
10 f: F,
11}
12
13impl<H, F> Around<H, F> {
14 #[inline]
16 pub const fn new(h: H, f: F) -> Self {
17 Self { h, f }
18 }
19}
20
21#[crate::async_trait]
22impl<H, F, I, O> Handler<I> for Around<H, F>
23where
24 I: Send + 'static,
25 H: Handler<I, Output = Result<O>> + Clone,
26 F: Handler<Next<I, H>, Output = H::Output>,
27{
28 type Output = F::Output;
29
30 async fn call(&self, i: I) -> Self::Output {
31 self.f.call((i, self.h.clone())).await
32 }
33}