pub struct TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> { /* private fields */ }Expand description
A complete installable trigger specification that emits activation and deactivation events when its paired criteria cause state changes.
Implementations§
Source§impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive>where
AC: TriggerCriterion,
DC: TriggerCriterion,
ActiveEv: IxaEvent,
InactiveEv: IxaEvent,
MakeActive: Fn(AC::Observation) -> ActiveEv + 'static,
MakeInactive: Fn(DC::Observation) -> InactiveEv + 'static,
impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive>where
AC: TriggerCriterion,
DC: TriggerCriterion,
ActiveEv: IxaEvent,
InactiveEv: IxaEvent,
MakeActive: Fn(AC::Observation) -> ActiveEv + 'static,
MakeInactive: Fn(DC::Observation) -> InactiveEv + 'static,
Sourcepub fn new(
activation_criterion: AC,
make_active_event: MakeActive,
deactivation_criterion: DC,
make_inactive_event: MakeInactive,
) -> Self
pub fn new( activation_criterion: AC, make_active_event: MakeActive, deactivation_criterion: DC, make_inactive_event: MakeInactive, ) -> Self
Create a repeating toggling trigger that starts inactive.
The activation criterion is accepted only while the trigger is inactive, and the deactivation criterion is accepted only while the trigger is active. Repeating mode means the trigger remains enabled after deactivation and can run through multiple active periods.
The component criteria are used as match sources. They should usually be repeating criteria;
configuring a component criterion with its own .once() can consume that criterion on a
match that this toggling trigger ignores because it occurred in the wrong state.
Sourcepub fn initially_active(self) -> Self
pub fn initially_active(self) -> Self
Start the trigger in the active state.
An initially active trigger ignores activation matches until it first accepts a
deactivation match. If the toggling trigger is also configured with Self::once, that
first accepted deactivation completes its one active period and permanently disables it.
Sourcepub fn initially_inactive(self) -> Self
pub fn initially_inactive(self) -> Self
Start the trigger in the inactive state.
This is the default state and is provided as an explicit counterpart to
Self::initially_active. If the toggling trigger is configured with Self::once, it can
accept one activation and then one deactivation before disabling itself.
Sourcepub fn once(self) -> Self
pub fn once(self) -> Self
Run through one active period and then permanently disable the toggling trigger.
This method sets the mode of the toggling trigger itself. It does not change the mode of the
activation or deactivation criteria supplied to Self::new. For an initially inactive
trigger, one active period consists of one accepted activation followed by one accepted
deactivation. For an initially active trigger, the active period is already in progress, so
the first accepted deactivation disables the trigger.