Trait pyri_state::pattern::StatePattern

source ·
pub trait StatePattern<S: State>: 'static + Send + Sync + Sized {
    // Required method
    fn matches(&self, state: &S) -> bool;

    // Provided methods
    fn will_update(
        self,
    ) -> impl 'static + Send + Sync + Fn(CurrentRef<'_, S>) -> bool { ... }
    fn on_update<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs { ... }
    fn will_exit(
        self,
    ) -> impl 'static + Send + Sync + Fn(CurrentRef<'_, S>) -> bool { ... }
    fn on_exit<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs { ... }
    fn will_disable(
        self,
    ) -> impl 'static + Send + Sync + Fn(FlushRef<'_, '_, S>) -> bool { ... }
    fn on_disable<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs { ... }
    fn will_enter(
        self,
    ) -> impl 'static + Send + Sync + Fn(NextRef<'_, '_, S>) -> bool { ... }
    fn on_enter<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs { ... }
    fn will_enable(
        self,
    ) -> impl 'static + Send + Sync + Fn(FlushRef<'_, '_, S>) -> bool { ... }
    fn on_enable<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs { ... }
}
Expand description

A type that can match a subset of values of the State type S.

If S implements Eq, it can be used directly as a state pattern.

See the following extension traits with additional bounds on Self and S:

Required Methods§

source

fn matches(&self, state: &S) -> bool

Check if the pattern matches a particular state.

Provided Methods§

source

fn will_update( self, ) -> impl 'static + Send + Sync + Fn(CurrentRef<'_, S>) -> bool

Build a run condition that checks if S is in a matching state.

source

fn on_update<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs

Configure systems to run if S is in a matching state.

source

fn will_exit(self) -> impl 'static + Send + Sync + Fn(CurrentRef<'_, S>) -> bool

Build a run condition that checks if S will exit a matching state if triggered.

source

fn on_exit<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs

Configure systems to run when S exits a matching state.

source

fn will_disable( self, ) -> impl 'static + Send + Sync + Fn(FlushRef<'_, '_, S>) -> bool

Build a run condition that checks if S will become disabled from a matching state if triggered.

source

fn on_disable<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs

Configure systems to run when S is disabled from a matching state.

source

fn will_enter( self, ) -> impl 'static + Send + Sync + Fn(NextRef<'_, '_, S>) -> bool

Build a run condition that checks if S will enter into a matching state if triggered.

source

fn on_enter<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs

Configure systems to run when S enters a matching state.

source

fn will_enable( self, ) -> impl 'static + Send + Sync + Fn(FlushRef<'_, '_, S>) -> bool

Build a run condition that checks if S will become enabled in a matching state if triggered.

source

fn on_enable<M>(self, systems: impl IntoSystemConfigs<M>) -> SystemConfigs

Configure systems to run when S becomes enabled in a matching state.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<S: State + Eq> StatePattern<S> for S

source§

impl<S: State> StatePattern<S> for AnyStatePattern<S>

source§

impl<S: State, F> StatePattern<S> for FnStatePattern<S, F>
where F: 'static + Send + Sync + Fn(&S) -> bool,