pub trait Reactor<T, S = ()> {
type Response;
type Error;
// Required method
fn react(
&mut self,
event: Timed<Event<T>>,
context: Context<'_, S>,
) -> Result<Self::Response, Self::Error>;
// Provided methods
fn map_response<P, F>(self, f: F) -> MapResponse<Self, F>
where Self: Sized,
F: FnMut(Self::Response) -> P { ... }
fn map_error<E, F>(self, f: F) -> MapError<Self, F>
where Self: Sized,
F: FnMut(Self::Error) -> E { ... }
fn respond<P>(self, response: P) -> Respond<Self, P>
where Self: Sized,
P: Clone { ... }
fn fail<E>(self, error: E) -> Fail<Self, E>
where Self: Sized,
E: Clone { ... }
fn then<R>(self, reactor: R) -> Then<Self, R>
where Self: Sized,
T: Clone,
R: Reactor<T, S> { ... }
fn and<R>(self, reactor: R) -> And<Self, R>
where Self: Sized,
Self::Error: From<R::Error>,
T: Clone,
R: Reactor<T, S> { ... }
fn or<R>(self, reactor: R) -> Or<Self, R>
where Self: Sized,
T: Clone,
R: Reactor<T, S, Response = Self::Response> { ... }
fn inspect<F>(
self,
f: F,
) -> impl Reactor<T, S, Response = Self::Response, Error = Self::Error>
where Self: Sized,
T: Clone,
F: FnMut(&Timed<Event<T>>, &Result<Self::Response, Self::Error>) { ... }
}
Expand description
Required Associated Types§
Required Methods§
Provided Methods§
fn map_response<P, F>(self, f: F) -> MapResponse<Self, F>
fn map_error<E, F>(self, f: F) -> MapError<Self, F>
Sourcefn respond<P>(self, response: P) -> Respond<Self, P>
fn respond<P>(self, response: P) -> Respond<Self, P>
Reacts with this reactor and then responds with the given response
, regardless of this
reactor’s output.
Sourcefn fail<E>(self, error: E) -> Fail<Self, E>
fn fail<E>(self, error: E) -> Fail<Self, E>
Reacts with this reactor and then fails with the given error
, regardless of this
reactor’s output.
Sourcefn then<R>(self, reactor: R) -> Then<Self, R>
fn then<R>(self, reactor: R) -> Then<Self, R>
Reacts with this reactor and then the given reactor (regardless of outputs).
The constructed reactor returns the output of the given (subsequent) reactor. See also the
event::then
function.
Sourcefn and<R>(self, reactor: R) -> And<Self, R>
fn and<R>(self, reactor: R) -> And<Self, R>
Reacts with this reactor and then the given reactor if and only if this reactor returns
Ok
.
The constructed reactor returns either an error from this reactor or the output of the
given (subsequent) reactor. See also the event::and
function.