Skip to main content

appletheia_application/messaging/
subscription.rs

1#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
2pub enum Subscription<'a, S> {
3    All,
4    Only(&'a [S]),
5}
6
7impl<'a, S> Subscription<'a, S> {
8    pub fn matches<M>(&self, message: &M) -> bool
9    where
10        S: super::Selector<M>,
11    {
12        match self {
13            Subscription::All => true,
14            Subscription::Only(selectors) => {
15                selectors.iter().any(|selector| selector.matches(message))
16            }
17        }
18    }
19}