Struct rotor::Response
[−]
[src]
pub struct Response<M, N>(_);
The response of a state machine to the (mio) action
This value is returned by many methods of the Machine
trait.
Methods
impl<M: Sized, N: Sized> Response<M, N>
fn ok(machine: M) -> Response<M, N>
fn spawn(machine: M, result: N) -> Response<M, N>
fn done() -> Response<M, N>
fn error(e: Box<Error>) -> Response<M, N>
fn deadline(self, time: Time) -> Response<M, N>
fn map<T, U, S, R>(self, self_mapper: S, result_mapper: R) -> Response<T, U> where S: FnOnce(M) -> T, R: FnOnce(N) -> U
Maps state machine and/or spawned result with a function
Usually it's okay to use constructor of wrapper state machine here as a mapper
fn wrap<T, S>(self, self_mapper: S) -> Response<T, N> where S: FnOnce(M) -> T
Similar to map
but only maps state machine
This is especially useful in state machine constructors, which have a Void child type.
fn is_stopped(&self) -> bool
Returns true if state machine is stopped
I.e. the method returns true if the Response
was created either with
Response::done
or Response::error
fn cause(&self) -> Option<&Error>
Return a reference to an error passed to Response::error
Returns None if any other constructor was used.
This is mostly useful for printing the error.
impl<M: Sized + Debug, N: Sized + Debug> Response<M, N>
fn expect_machine(self) -> M
Return state machine if response created with Response::ok(..)
Use only for unit tests
If the response is not okay, the function panics.
fn expect_spawn(self) -> (M, N)
Return a tuple if response created with Response::spawn(..)
Use only for unit tests
If the response is not spawn
, the function panics.
fn expect_done(self)
Returns if response created with Response::done()
Use only for unit tests
If the response is not done, the function panics.
fn expect_error(self) -> Box<Error>
Returns an error if response created with Response::error(..)
Use only for unit tests
If the response does not contain error, the function panics.