#[non_exhaustive]pub enum StopReason {
Cancelled,
TimedOut,
}Expand description
Why an operation was stopped.
This is returned from Stop::check() when the
operation should stop.
§Error Integration
Implement From<StopReason> for your error type to use ? naturally:
use enough::StopReason;
#[derive(Debug)]
enum MyError {
Stopped(StopReason),
Io(std::io::Error),
}
impl From<StopReason> for MyError {
fn from(r: StopReason) -> Self { MyError::Stopped(r) }
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Cancelled
Operation was explicitly cancelled.
This typically means someone called cancel() on a cancellation source,
or a parent operation was cancelled.
TimedOut
Operation exceeded its deadline.
This means a timeout was set and the deadline passed before the operation completed.
Implementations§
Source§impl StopReason
impl StopReason
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Returns true if this is a transient condition that might succeed on retry.
Currently only TimedOut is considered transient, as the operation might
succeed with a longer timeout or under less load.
Cancelled is not transient - it represents an explicit decision to stop.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true if this was an explicit cancellation.
Sourcepub fn is_timed_out(&self) -> bool
pub fn is_timed_out(&self) -> bool
Returns true if this was a timeout.
Trait Implementations§
Source§impl Clone for StopReason
impl Clone for StopReason
Source§fn clone(&self) -> StopReason
fn clone(&self) -> StopReason
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more