TriggerCondition

Enum TriggerCondition 

Source
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: Event

The event to count.

§required: usize

The amount of times this event needs to be received for the condition to trigger.

§

Greater

Trigger when an event is received that is greater than the reference event.

Fields

§reference_event: Event

The 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: Event

The reference event to compare against.

§

Equal

Trigger when an event is received that is equal to the reference event.

Fields

§reference_event: Event

The 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: Event

The reference event to compare against.

§

Less

Trigger when an event is received that is less than the reference event.

Fields

§reference_event: Event

The 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.

§n: usize

The amount of conditions that need to be fulfilled.

Implementations§

Source§

impl<Event> TriggerCondition<Event>

Source

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>

Source§

type Output = TriggerCondition<Event>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl<Event: Clone> BitAndAssign for TriggerCondition<Event>

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl<Event> BitOr for TriggerCondition<Event>

Source§

type Output = TriggerCondition<Event>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl<Event: Clone> BitOrAssign for TriggerCondition<Event>

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl<Event: Clone> Clone for TriggerCondition<Event>

Source§

fn clone(&self) -> TriggerCondition<Event>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Event: Debug> Debug for TriggerCondition<Event>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Event: PartialEq> PartialEq for TriggerCondition<Event>

Source§

fn eq(&self, other: &TriggerCondition<Event>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Event: Eq> Eq for TriggerCondition<Event>

Source§

impl<Event> StructuralPartialEq for TriggerCondition<Event>

Auto Trait Implementations§

§

impl<Event> Freeze for TriggerCondition<Event>
where Event: Freeze,

§

impl<Event> RefUnwindSafe for TriggerCondition<Event>
where Event: RefUnwindSafe,

§

impl<Event> Send for TriggerCondition<Event>
where Event: Send,

§

impl<Event> Sync for TriggerCondition<Event>
where Event: Sync,

§

impl<Event> Unpin for TriggerCondition<Event>
where Event: Unpin,

§

impl<Event> UnwindSafe for TriggerCondition<Event>
where Event: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ConditionalSerde for T