CallbackRegistry

Struct CallbackRegistry 

Source
pub struct CallbackRegistry<SM: StateMachine> { /* private fields */ }
Expand description

Callback registry for state machine events

This structure manages callbacks for state machine events including:

  • State entry callbacks: triggered when entering a state
  • State exit callbacks: triggered when leaving a state
  • Transition callbacks: triggered during state transitions

Implementations§

Source§

impl<SM: StateMachine> CallbackRegistry<SM>

Source

pub fn new() -> Self

Create a new callback registry

Source

pub fn on_state_entry<F>(&mut self, state: SM::State, callback: F)
where F: Fn(&SM::State) + Send + Sync + 'static,

Register a callback for when entering a specific state

§Arguments
  • state - The state to monitor for entry
  • callback - The callback function to execute
Source

pub fn on_state_exit<F>(&mut self, state: SM::State, callback: F)
where F: Fn(&SM::State) + Send + Sync + 'static,

Register a callback for when exiting a specific state

§Arguments
  • state - The state to monitor for exit
  • callback - The callback function to execute
Source

pub fn on_transition<F>( &mut self, from_state: SM::State, input: SM::Input, callback: F, )
where F: Fn(&SM::State, &SM::Input, &SM::State) + Send + Sync + 'static,

Register a callback for a specific transition

§Arguments
  • from_state - The source state
  • input - The input that triggers the transition
  • callback - The callback function to execute
Source

pub fn on_any_state_entry<F>(&mut self, callback: F)
where F: Fn(&SM::State) + Send + Sync + 'static,

Register a global callback that triggers on any state entry

§Arguments
  • callback - The callback function to execute
Source

pub fn on_any_state_exit<F>(&mut self, callback: F)
where F: Fn(&SM::State) + Send + Sync + 'static,

Register a global callback that triggers on any state exit

§Arguments
  • callback - The callback function to execute
Source

pub fn on_any_transition<F>(&mut self, callback: F)
where F: Fn(&SM::State, &SM::Input, &SM::State) + Send + Sync + 'static,

Register a global callback that triggers on any transition

§Arguments
  • callback - The callback function to execute
Source

pub fn clear(&mut self)

Clear all callbacks

Source

pub fn callback_count(&self) -> usize

Get the number of registered callbacks

Trait Implementations§

Source§

impl<SM: StateMachine> Debug for CallbackRegistry<SM>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<SM: StateMachine> Default for CallbackRegistry<SM>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<SM> Freeze for CallbackRegistry<SM>

§

impl<SM> !RefUnwindSafe for CallbackRegistry<SM>

§

impl<SM> Send for CallbackRegistry<SM>
where <SM as StateMachine>::State: Send, <SM as StateMachine>::Input: Send,

§

impl<SM> Sync for CallbackRegistry<SM>
where <SM as StateMachine>::State: Sync, <SM as StateMachine>::Input: Sync,

§

impl<SM> Unpin for CallbackRegistry<SM>
where <SM as StateMachine>::State: Unpin, <SM as StateMachine>::Input: Unpin,

§

impl<SM> !UnwindSafe for CallbackRegistry<SM>

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
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.

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.