pub enum TriggerCondition<Event> {
None,
Never,
EventCount {
event: Event,
required: usize,
},
Greater {
reference_event: Event,
},
GreaterOrEqual {
reference_event: Event,
},
Equal {
reference_event: Event,
},
LessOrEqual {
reference_event: Event,
},
Less {
reference_event: Event,
},
Sequence {
conditions: Vec<TriggerCondition<Event>>,
},
And {
conditions: Vec<TriggerCondition<Event>>,
},
Or {
conditions: Vec<TriggerCondition<Event>>,
},
AnyN {
conditions: Vec<TriggerCondition<Event>>,
n: usize,
},
}Expand description
The (uncompiled) trigger conditions for events.
Each condition triggers at most once.
Variants§
None
No trigger condition, this condition is always fulfilled.
Never
The unfulfillable trigger condition. This condition is never fulfilled.
EventCount
Trigger after a certain number of events have been received.
Fields
event: EventThe event to count.
Greater
Trigger when an event is received that is greater than the reference event.
Fields
reference_event: EventThe reference event to compare against.
GreaterOrEqual
Trigger when an event is received that is greater than or equal to the reference event.
Fields
reference_event: EventThe reference event to compare against.
Equal
Trigger when an event is received that is equal to the reference event.
Fields
reference_event: EventThe reference event to compare against.
LessOrEqual
Trigger when an event is received that is less than or equal to the reference event.
Fields
reference_event: EventThe reference event to compare against.
Less
Trigger when an event is received that is less than the reference event.
Fields
reference_event: EventThe reference event to compare against.
Sequence
Trigger when the given conditions have been fulfilled in sequence.
This works by having a pointer to the current active condition in the sequence. Whenever a condition is fulfilled, the pointer gets moved to the right. If it has visited all conditions, then this condition triggers.
Fields
conditions: Vec<TriggerCondition<Event>>The sequence of conditions.
And
Triggers after all given conditions have been fulfilled in any order.
This can be constructed via the BitAnd operator.
Compared to Self::Sequence, this does not require to fulfil the conditions in any order.
§Example
use event_trigger_action_system::*;
assert_eq!(none() & never(), TriggerCondition::<()>::And {conditions: vec![none(), never()]});Fields
conditions: Vec<TriggerCondition<Event>>The conditions to fulfil.
Or
Triggers after one of the given conditions have been fulfilled.
This can be constructed via the BitOr operator.
§Example
use event_trigger_action_system::*;
assert_eq!(none() | never(), TriggerCondition::<()>::Or {conditions: vec![none(), never()]});Fields
conditions: Vec<TriggerCondition<Event>>The conditions to fulfil.
AnyN
Triggers after a given number of the given conditions have been fulfilled.
Fields
conditions: Vec<TriggerCondition<Event>>The conditions to fulfil.
Implementations§
Source§impl<Event> TriggerCondition<Event>
impl<Event> TriggerCondition<Event>
Sourcepub fn compile<EventCompiler: Fn(Event) -> CompiledEvent, CompiledEvent: TriggerEvent>(
self,
event_compiler: &EventCompiler,
) -> CompiledTriggerCondition<CompiledEvent>
pub fn compile<EventCompiler: Fn(Event) -> CompiledEvent, CompiledEvent: TriggerEvent>( self, event_compiler: &EventCompiler, ) -> CompiledTriggerCondition<CompiledEvent>
Compile this trigger condition.
Raw event information is transformed into a more compact identifier for a matching compiled event.
Trait Implementations§
Source§impl<Event> BitAnd for TriggerCondition<Event>
impl<Event> BitAnd for TriggerCondition<Event>
Source§impl<Event: Clone> BitAndAssign for TriggerCondition<Event>
impl<Event: Clone> BitAndAssign for TriggerCondition<Event>
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl<Event> BitOr for TriggerCondition<Event>
impl<Event> BitOr for TriggerCondition<Event>
Source§impl<Event: Clone> BitOrAssign for TriggerCondition<Event>
impl<Event: Clone> BitOrAssign for TriggerCondition<Event>
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl<Event: Clone> Clone for TriggerCondition<Event>
impl<Event: Clone> Clone for TriggerCondition<Event>
Source§fn clone(&self) -> TriggerCondition<Event>
fn clone(&self) -> TriggerCondition<Event>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more