1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use crate::{async_trait, Handler};
#[derive(Clone)]
pub enum Either<L, R> {
Left(L),
Right(R),
}
#[async_trait]
impl<L, R, I, O> Handler<I> for Either<L, R>
where
I: Send + 'static,
L: Handler<I, Output = O> + Clone,
R: Handler<I, Output = O> + Clone,
{
type Output = O;
async fn call(&self, i: I) -> Self::Output {
match self {
Self::Left(l) => l.call(i).await,
Self::Right(r) => r.call(i).await,
}
}
}