pub struct BasicAsyncBuilder<Ev>where
    Ev: Debug,
{ /* private fields */ }
Available on crate feature async only.
Expand description

The BasicAsyncBuilder helps you to create a BasicAsyncMediator.

The BasicAsyncBuilder is part of the builder pattern. It has only two functionalities. The first one is adding a Listener via BasicAsyncBuilder::add_listener(). The second one is the mandatory BuilderFlow::build(), which returns a BasicAsyncMediator.

Implementations

Adds a user-defined listener to the BasicAsyncBuilder.

The supplied type must be a Listener. As such, it must implement Send and Fn(Ev), besides being 'static.

As a side note, here, Ev is the user-defined event type that must be Clone and Debug.

Examples

Basic usage:

use mediator_sys::asynchronous::basic::*;

#[derive(Debug, Clone)]
enum MyEvent {
    One,
    Two
}

let mediator = BasicAsyncMediator::<MyEvent>::builder()
    .add_listener(|ev| {
        /* Your listening logic */
    })
    .build();

Trait Implementations

Adds a user-defined listener to the BasicAsyncBuilder.

To be able to supply a closure that implements Listener, it must satisfy Send and 'static bounds.

Also it must be a Fn(Ev) with a return type of () where Ev is the user-defined event type that must be Clone and Debug.

Builds the BasicAsyncMediator and returns it.

Because BasicAsyncMediator implements BuilderInternal, which in turn means, that the BasicAsyncBuilder implements BuilderFlow and not crate::builder::TryBuilderFlow, this method will always return a BasicAsyncMediator as stated by the return type.

Creates a BasicAsyncBuilder with the goal of producing a BasicAsyncMediator.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.