Skip to main content

UseStateHandle

Trait UseStateHandle 

Source
pub trait UseStateHandle<S, T, G>: HasStateHandle<T, G>
where Self: 'static, S: 'static + Clone + Debug + PartialEq + Send, T: 'static + Clone + Debug + PartialEq + Send + Sync, G: 'static + Clone + Debug + Eq + Hash + Send + Sync,
{ // Provided method fn subscribe<'async_trait>( self: Arc<Self>, reader: Reader<S, T>, tag: G, ) -> Pin<Box<dyn Future<Output = Handle<T>> + Send + 'async_trait>> where Self: Sync + Send + 'async_trait { ... } }
Expand description

Convenient method to do subscription with a state convert function. The trait is auto implemented for types implemented HasStateHandle.

Provided Methods§

Source

fn subscribe<'async_trait>( self: Arc<Self>, reader: Reader<S, T>, tag: G, ) -> Pin<Box<dyn Future<Output = Handle<T>> + Send + 'async_trait>>
where Self: Sync + Send + 'async_trait,

Do subscription with a state convert function.

  • stage [1] – receive from source’s broadcast channel.
  • stage [2] – convert to target type and send to mpsc channel.
  • stage [3] – receive from mpsc channel and process it.
  • stage [4] – (optional) feedback when the change event has been processed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<V, S, T, G> UseStateHandle<S, T, G> for V
where V: 'static + HasStateHandle<T, G>, S: 'static + Clone + Debug + PartialEq + Send, T: 'static + Clone + Debug + PartialEq + Send + Sync, G: 'static + Clone + Debug + Eq + Hash + Send + Sync,