ragnarok/
potential_event.rs

1use crate::{
2    NameOfEvent,
3    NodeKey,
4    SourceEvent,
5};
6
7/// Potential events are events that might get emitted or not.
8#[derive(Clone, Debug, PartialEq)]
9pub struct PotentialEvent<Key: NodeKey, Name: NameOfEvent, Source: SourceEvent> {
10    pub node_key: Key,
11    pub name: Name,
12    pub source_event: Source,
13    pub layer: i16,
14}
15
16impl<Key: NodeKey, Name: NameOfEvent, Source: SourceEvent> Eq
17    for PotentialEvent<Key, Name, Source>
18{
19}
20
21impl<Key: NodeKey, Name: NameOfEvent, Source: SourceEvent> PartialOrd
22    for PotentialEvent<Key, Name, Source>
23{
24    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
25        Some(self.cmp(other))
26    }
27}
28
29impl<Key: NodeKey, Name: NameOfEvent, Source: SourceEvent> Ord
30    for PotentialEvent<Key, Name, Source>
31{
32    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
33        other
34            .layer
35            .cmp(&self.layer)
36            .then_with(|| self.name.cmp(&other.name))
37    }
38}