pub struct Response<M, N>(/* private fields */);Expand description
The response of a state machine to the (mio) action
This value is returned by many methods of the Machine trait.
Implementations§
Source§impl<M: Sized, N: Sized> Response<M, N>
impl<M: Sized, N: Sized> Response<M, N>
pub fn ok(machine: M) -> Response<M, N>
pub fn spawn(machine: M, result: N) -> Response<M, N>
pub fn done() -> Response<M, N>
pub fn error(e: Box<dyn Error>) -> Response<M, N>
pub fn deadline(self, time: Time) -> Response<M, N>
Sourcepub fn map<T, U, S, R>(self, self_mapper: S, result_mapper: R) -> Response<T, U>
pub fn map<T, U, S, R>(self, self_mapper: S, result_mapper: R) -> Response<T, 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
Sourcepub fn wrap<T, S>(self, self_mapper: S) -> Response<T, N>where
S: FnOnce(M) -> T,
pub 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.
Sourcepub fn is_stopped(&self) -> bool
pub 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
Source§impl<M: Sized + Debug, N: Sized + Debug> Response<M, N>
impl<M: Sized + Debug, N: Sized + Debug> Response<M, N>
Sourcepub fn expect_machine(self) -> M
pub 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.
Sourcepub fn expect_spawn(self) -> (M, N)
pub 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.
Sourcepub fn expect_done(self)
pub 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.
Sourcepub fn expect_error(self) -> Box<dyn Error>
pub fn expect_error(self) -> Box<dyn 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.