Behavior

Trait Behavior 

Source
pub trait Behavior:
    Component<Mutability = Mutable>
    + Debug
    + Sized {
    // Provided methods
    fn filter_yield(&self, next: &Self) -> bool { ... }
    fn filter_next(&self, next: &Self) -> bool { ... }
    fn is_resumable(&self) -> bool { ... }
    fn on_start(
        &self,
        _previous: Option<&Self>,
        _commands: InstanceCommands<'_, Self>,
    ) { ... }
    fn on_pause(&self, _current: &Self, _commands: InstanceCommands<'_, Self>) { ... }
    fn on_resume(&self, _previous: &Self, _commands: InstanceCommands<'_, Self>) { ... }
    fn on_stop(&self, _current: &Self, _commands: InstanceCommands<'_, Self>) { ... }
    fn on_activate(
        &self,
        _previous: Option<&Self>,
        _commands: InstanceCommands<'_, Self>,
    ) { ... }
    fn on_suspend(&self, _current: &Self, _commands: InstanceCommands<'_, Self>) { ... }
}
Expand description

Any Component which may be used as a Behavior.

§Usage

A Behavior is a component which represents a set of finite states. This makes enum the ideal data structure to implement this trait, however this is not a strict requirement.

Provided Methods§

Source

fn filter_yield(&self, next: &Self) -> bool

Called when an interrupt is requested.

If this returns true, the current behavior will stop to allow the next behavior to start. The initial behavior is never allowed to yield.

Source

fn filter_next(&self, next: &Self) -> bool

Called before a new behavior is started.

If this returns false, the transition fails. See Error for details on how to handle transition failures.

Source

fn is_resumable(&self) -> bool

Called after a behavior is paused.

If this returns false, the paused behavior will be stopped immediatedly and discarded. No Pause event will be sent in this case.

Source

fn on_start( &self, _previous: Option<&Self>, _commands: InstanceCommands<'_, Self>, )

Called during transition just after the behavior is started.

Source

fn on_pause(&self, _current: &Self, _commands: InstanceCommands<'_, Self>)

Called during transition just after the behavior is paused.

Source

fn on_resume(&self, _previous: &Self, _commands: InstanceCommands<'_, Self>)

Called during transition just after the behavior is resumed.

Source

fn on_stop(&self, _current: &Self, _commands: InstanceCommands<'_, Self>)

Called during transition just after the behavior is stopped.

Source

fn on_activate( &self, _previous: Option<&Self>, _commands: InstanceCommands<'_, Self>, )

Called during transition just after the behavior is started or resumed.

Source

fn on_suspend(&self, _current: &Self, _commands: InstanceCommands<'_, Self>)

Called during transition just after the behavior is paused or stopped.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§