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