pub trait BehaviorItem {
// Required methods
fn current(&self) -> &Self::Behavior;
fn previous(&self) -> Option<&Self::Behavior>;
fn current_index(&self) -> BehaviorIndex;
fn enumerate(
&self,
) -> impl Iterator<Item = (BehaviorIndex, &Self::Behavior)> + '_;
fn get(&self, index: BehaviorIndex) -> Option<&Self::Behavior>;
fn has_transition(&self) -> bool;
// Provided methods
fn index(&self) -> BehaviorIndex { ... }
fn has_index(&self, index: BehaviorIndex) -> bool { ... }
fn iter(&self) -> impl Iterator<Item = &Self::Behavior> + '_ { ... }
}Expand description
Common interface for querying Behavior state using a BehaviorRef or BehaviorMut.
Required Methods§
Sourcefn current_index(&self) -> BehaviorIndex
fn current_index(&self) -> BehaviorIndex
Returns the BehaviorIndex associated with the current Behavior state.
Sourcefn enumerate(
&self,
) -> impl Iterator<Item = (BehaviorIndex, &Self::Behavior)> + '_
fn enumerate( &self, ) -> impl Iterator<Item = (BehaviorIndex, &Self::Behavior)> + '_
Returns an iterator over all (BehaviorIndex, Behavior) pairs in the stack, including the current one.
The iterator is ordered from the initial behavior (index = 0) to the current one.
Sourcefn get(&self, index: BehaviorIndex) -> Option<&Self::Behavior>
fn get(&self, index: BehaviorIndex) -> Option<&Self::Behavior>
Returns a reference to the Behavior at the given BehaviorIndex, if it exists.
Sourcefn has_transition(&self) -> bool
fn has_transition(&self) -> bool
Returns true if there is any pending Transition for this Behavior.
§Usage
By design, only one transition is allowed per transition cycle.
The only exception to this rule is if the behavior is interrupted or reset where multiple states may be stopped within a single cycle.
If a transition is requested while another is pending, it would be overriden.
The transition helper methods start, interrupt_start,
stop and reset all trigger a warning in this case.
Because of this, this method is useful to avoid unintentional transition overrides.
Provided Methods§
Sourcefn index(&self) -> BehaviorIndex
👎Deprecated since 0.3.1: use current_index instead
fn index(&self) -> BehaviorIndex
current_index insteadReturns the BehaviorIndex associated with the current Behavior state.
Sourcefn has_index(&self, index: BehaviorIndex) -> bool
fn has_index(&self, index: BehaviorIndex) -> bool
Returns true if the given BehaviorIndex matches a state in this Behavior stack.
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.