pub struct TransitionError { /* private fields */ }Expand description
Message-only error produced by the return_recover! macro family
The macros convert this into the implementor’s error type via Into, so implementors with a
TryTransitionable::Error other than TransitionError must provide a
From<TransitionError> impl to use them:
use statecraft::{return_recover, Recovered, SelfTransitionable, State, Stateful, TransitionError, Transitionable, TryTransitionable};
#[derive(Debug)]
enum ServerError {
Transition(TransitionError),
}
impl From<TransitionError> for ServerError {
fn from(err: TransitionError) -> Self {
ServerError::Transition(err)
}
}
impl TryTransitionable<Running, Init> for Server<Init> {
type SuccessStateful = Server<Running>;
type FailureStateful = Server<Init>;
type Error = ServerError;
fn try_transition(
self,
) -> Result<Self::SuccessStateful, Recovered<Self::FailureStateful, Self::Error>> {
return_recover!(self, "We always fail :(")
}
}A TransitionError TryTransitionable::Error converts as-is, and a boxed error type like
Box<dyn std::error::Error + Send + Sync> converts through the standard library’s blanket
boxing impl.
Implementations§
Trait Implementations§
Source§impl Debug for TransitionError
impl Debug for TransitionError
Source§impl Display for TransitionError
impl Display for TransitionError
Source§impl Error for TransitionError
impl Error for TransitionError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for TransitionError
impl RefUnwindSafe for TransitionError
impl Send for TransitionError
impl Sync for TransitionError
impl Unpin for TransitionError
impl UnsafeUnpin for TransitionError
impl UnwindSafe for TransitionError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more