Skip to main content

TogglingTrigger

Struct TogglingTrigger 

Source
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,

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn repeating(self) -> Self

Keep the toggling trigger enabled after deactivation so it can activate again.

This is the default mode. 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.

Trait Implementations§

Source§

impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> TriggerSpec for 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,

Source§

fn install_in_context(self, context: &mut Context)

Auto Trait Implementations§

§

impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> Freeze for TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive>
where AC: Freeze, DC: Freeze, MakeActive: Freeze, MakeInactive: Freeze,

§

impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> RefUnwindSafe for TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive>
where AC: RefUnwindSafe, DC: RefUnwindSafe, MakeActive: RefUnwindSafe, MakeInactive: RefUnwindSafe,

§

impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> Send for TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive>
where AC: Send, DC: Send, MakeActive: Send, MakeInactive: Send,

§

impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> Sync for TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive>
where AC: Sync, DC: Sync, MakeActive: Sync, MakeInactive: Sync,

§

impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> Unpin for TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive>
where AC: Unpin, DC: Unpin, MakeActive: Unpin, MakeInactive: Unpin,

§

impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> UnsafeUnpin for TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive>
where AC: UnsafeUnpin, DC: UnsafeUnpin, MakeActive: UnsafeUnpin, MakeInactive: UnsafeUnpin,

§

impl<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive> UnwindSafe for TogglingTrigger<AC, DC, ActiveEv, InactiveEv, MakeActive, MakeInactive>
where AC: UnwindSafe, DC: UnwindSafe, MakeActive: UnwindSafe, MakeInactive: 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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> 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.

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,