Skip to main content

UseStateMachine

Trait UseStateMachine 

Source
pub trait UseStateMachine<G>: HasStateMachine<G>
where G: 'static + Clone + Debug + Eq + Hash + Send + Sync,
{
Show 18 methods // Provided methods fn add_source<'life0, 'async_trait, S>( &'life0 self, tag: G, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait { ... } fn add_source_ex<'life0, 'async_trait, S>( &'life0 self, tag: G, chan_capacity: usize, init_value: S, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait { ... } fn del_source<'life0, 'life1, 'async_trait>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn has_source<'life0, 'life1, 'async_trait>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn num_of_subscriptions<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn source_value<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = S> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn source_value_ex<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = Value<S>> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn change<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, s: S, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn wait_change<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, s: S, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn modify<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, func: impl 'async_trait + Fn(S) -> S + Send + Sync + 'static, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn wait_modify<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, func: impl 'async_trait + Fn(S) -> S + Send + Sync + 'static, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn touch<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn has_handle<'life0, 'life1, 'async_trait>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn handle_value<'life0, 'life1, 'async_trait, T>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = T> + Send + 'async_trait>> where T: 'static + Clone + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn handle_value_ex<'life0, 'life1, 'async_trait, T>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = Value<T>> + Send + 'async_trait>> where T: 'static + Clone + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn reader<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = Reader<S>> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn reader_ex<'life0, 'life1, 'async_trait, S, T>( &'life0 self, tag: &'life1 G, func: impl 'async_trait + Fn(S) -> Pin<Box<dyn Future<Output = T> + Send>> + Send + Sync + 'static, ) -> Pin<Box<dyn Future<Output = ReaderEx<S, T>> + Send + 'async_trait>> where S: 'static + Clone + Default + PartialEq + Send + 'async_trait, T: 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn unsubscribe<'life0, 'life1, 'async_trait, T>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where T: 'static + Clone + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

Some convenient methods to use state machine. The trait is auto implemented for types implemented HasStateMachine.

Provided Methods§

Source

fn add_source<'life0, 'async_trait, S>( &'life0 self, tag: G, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Add source to state machine, the source is created by default.

Source

fn add_source_ex<'life0, 'async_trait, S>( &'life0 self, tag: G, chan_capacity: usize, init_value: S, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Add source to state machine.

Source

fn del_source<'life0, 'life1, 'async_trait>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete source from state machine.

Source

fn has_source<'life0, 'life1, 'async_trait>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

If source of tag exists in state machine.

Source

fn num_of_subscriptions<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Num of subscriptions.

Source

fn source_value<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = S> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get current value of source.

Source

fn source_value_ex<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = Value<S>> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get current value of source with timestamp.

Source

fn change<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, s: S, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Change state of source.

Source

fn wait_change<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, s: S, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Change state of source, and wait responders to finish actions upon the change event.

Source

fn modify<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, func: impl 'async_trait + Fn(S) -> S + Send + Sync + 'static, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Change state of source by modifying it with a func.

Source

fn wait_modify<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, func: impl 'async_trait + Fn(S) -> S + Send + Sync + 'static, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Change state of source by modifying it with a func, and wait responders to finish actions upon the change event.

Source

fn touch<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = Result<(), SourceChangeError>> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a change event without changing state of source really.

Source

fn has_handle<'life0, 'life1, 'async_trait>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

If handle of tag exists in state machine.

Source

fn handle_value<'life0, 'life1, 'async_trait, T>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = T> + Send + 'async_trait>>
where T: 'static + Clone + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get current value of handle.

Source

fn handle_value_ex<'life0, 'life1, 'async_trait, T>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = Value<T>> + Send + 'async_trait>>
where T: 'static + Clone + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get current value of handle with timestamp.

Source

fn reader<'life0, 'life1, 'async_trait, S>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = Reader<S>> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get reader of source, can be subscribed by responders.

Source

fn reader_ex<'life0, 'life1, 'async_trait, S, T>( &'life0 self, tag: &'life1 G, func: impl 'async_trait + Fn(S) -> Pin<Box<dyn Future<Output = T> + Send>> + Send + Sync + 'static, ) -> Pin<Box<dyn Future<Output = ReaderEx<S, T>> + Send + 'async_trait>>
where S: 'static + Clone + Default + PartialEq + Send + 'async_trait, T: 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get reader of source, can be subscribed by responders.

Source

fn unsubscribe<'life0, 'life1, 'async_trait, T>( &'life0 self, tag: &'life1 G, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where T: 'static + Clone + PartialEq + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unsubscription

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T, G> UseStateMachine<G> for T
where T: HasStateMachine<G>, G: 'static + Clone + Debug + Eq + Hash + Send + Sync,