AsyncReducible

Trait AsyncReducible 

Source
pub trait AsyncReducible: Send {
    type Input: Send;

    // Required methods
    fn init() -> impl Future<Output = Self> + Send;
    fn reduce(
        &mut self,
        input: Self::Input,
    ) -> impl Future<Output = bool> + Send;
}
Expand description

A trait that implements an async reducer function.

For more information, see AsyncReducer.

Required Associated Types§

Source

type Input: Send

The input message type used to modify the data.

Required Methods§

Source

fn init() -> impl Future<Output = Self> + Send

Initialize the data.

Source

fn reduce(&mut self, input: Self::Input) -> impl Future<Output = bool> + Send

Process the input message and update the state asynchronously.

Return true to notify all subscribers. Return false to ignore all subscribers.

For example, it makes sense to return false to indicate that the message had no (noteworthy) effect on the data and the subscribers don’t need to be notified.

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.

Implementors§