Skip to main content

HasStateHandle

Trait HasStateHandle 

Source
pub trait HasStateHandle<T, G>: HasStateMachine<G>
where T: Clone + Debug + PartialEq, G: Clone + Debug + Eq + Hash,
{ // Required method fn on_change<'async_trait>( self: Arc<Self>, tag: G, new_value: T, old_value: T, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + Send + 'async_trait>> where Self: 'async_trait; }
Expand description

Define action upon state change event.

  • T - type of state in handle,
  • G - to distinguish different initiators or responders, all initiators must use different tag values, all responders, and all responders do the same, a same tag value can be used by an initiator and a responder in the same state machine.

Required Methods§

Source

fn on_change<'async_trait>( self: Arc<Self>, tag: G, new_value: T, old_value: T, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + Send + 'async_trait>>
where Self: 'async_trait,

Action upon state change event.

  • tag - the tag value
  • new_value - the new value just received
  • old_value - the value received last time, it should be ‘None’ at the first time.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§