pub struct BasicAsyncBuilder<Ev>where
Ev: Debug,{ /* private fields */ }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§
Source§impl<Ev> BasicAsyncBuilder<Ev>where
Ev: Debug,
impl<Ev> BasicAsyncBuilder<Ev>where
Ev: Debug,
Sourcepub fn add_listener<F>(self, f: F) -> Selfwhere
F: Listener<Ev>,
pub fn add_listener<F>(self, f: F) -> Selfwhere
F: Listener<Ev>,
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§
Source§impl<M, Ev> BasicMediatorBuilderInterface<M, Ev> for BasicAsyncBuilder<Ev>where
Ev: Debug,
impl<M, Ev> BasicMediatorBuilderInterface<M, Ev> for BasicAsyncBuilder<Ev>where
Ev: Debug,
Source§fn add_listener<F>(self, f: F) -> Selfwhere
F: Listener<Ev>,
fn add_listener<F>(self, f: F) -> Selfwhere
F: Listener<Ev>,
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.
Source§impl<Ev> BuilderFlow<BasicAsyncMediator<Ev>> for BasicAsyncBuilder<Ev>where
Ev: Debug,
impl<Ev> BuilderFlow<BasicAsyncMediator<Ev>> for BasicAsyncBuilder<Ev>where
Ev: Debug,
Source§fn build(self) -> BasicAsyncMediator<Ev>
fn build(self) -> BasicAsyncMediator<Ev>
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.
Source§impl<Ev> BuilderInternal<BasicAsyncMediator<Ev>, BasicAsyncBuilder<Ev>> for BasicAsyncMediator<Ev>where
Ev: Debug,
impl<Ev> BuilderInternal<BasicAsyncMediator<Ev>, BasicAsyncBuilder<Ev>> for BasicAsyncMediator<Ev>where
Ev: Debug,
Source§fn builder() -> BasicAsyncBuilder<Ev>
fn builder() -> BasicAsyncBuilder<Ev>
Creates a BasicAsyncBuilder with the goal of producing a BasicAsyncMediator.