pub struct BasicBuilder<Ev>where
    Ev: Debug,
{ /* private fields */ }
Expand description

The BasicBuilder helps you to create a BasicMediator.

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

Implementations

Adds a user-defined listener to the BasicBuilder.

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::synchronous::basic::*;

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

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

Trait Implementations

Adds a user-defined listener to the BasicBuilder.

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 BasicMediator and returns it.

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

Creates a BasicBuilder with the goal of producing a BasicMediator.

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.