Skip to main content

aionbot_core/router/
logic.rs

1use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
2
3use crate::event::Event;
4
5use super::Router;
6
7#[derive(Default)]
8pub struct AllRouter;
9
10impl Router for AllRouter {
11    fn matches(&self, _event: &dyn Event) -> bool {
12        true
13    }
14}
15
16pub struct AnyRouter {
17    pub routers: Vec<Box<dyn Router>>,
18}
19
20impl Router for AnyRouter {
21    fn matches(&self, event: &dyn Event) -> bool {
22        self.routers.par_iter().any(|r| r.matches(event))
23    }
24}
25
26impl AnyRouter {
27    pub fn new(routers: Vec<Box<dyn Router>>) -> Self {
28        Self { routers }
29    }
30}