#[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 CategorizedError for StopReason
impl CategorizedError for StopReason
Source§fn codec_name(&self) -> Option<&'static str>
fn codec_name(&self) -> Option<&'static str>
Some("zenjpeg")). A codec returns a
constant here on its error type so CodecError::from_native /
of can tag the envelope from the value — no separate
argument. Required: there is deliberately no default, so every
implementor must answer it. The zencodec cause types (LimitExceeded,
UnsupportedOperation, enough::StopReason) implement it as None
since they aren’t codecs. Read moreSource§fn category(&self) -> ErrorCategory
fn category(&self) -> ErrorCategory
ErrorCategory.Source§impl Clone for StopReason
impl Clone for StopReason
Source§fn clone(&self) -> StopReason
fn clone(&self) -> StopReason
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more