pub struct ResourceTemporarilyUnavailableError { /* private fields */ }
Expand description
An error which is returned when an underlying resource is unavailable.
This error can be handled by retrying, usually in a loop with a small delay.
Implementations§
Sourcepub fn from_source(source: Box<dyn Error>) -> Self
pub fn from_source(source: Box<dyn Error>) -> Self
Constructs a new ResourceTemporarilyUnavailableError
from a specified source error.
The implementation of std::fmt::Display
for this error will simply pass through the
display of the source message unmodified.
§Examples
use grid_sdk::error::ResourceTemporarilyUnavailableError;
let io_err = std::io::Error::new(std::io::ErrorKind::Other, "io error");
let rtu_error = ResourceTemporarilyUnavailableError::from_source(Box::new(io_err));
assert_eq!(format!("{}", rtu_error), "io error");
Sourcepub fn from_source_with_hint(
source: Box<dyn Error>,
retry_duration_hint: Duration,
) -> Self
pub fn from_source_with_hint( source: Box<dyn Error>, retry_duration_hint: Duration, ) -> Self
Constructs a new ResourceTemporarilyUnavailableError
from a specified source error with
a retry duration hint.
The hint specified here can be used by the caller as the duration between retry attempts.
Callers may ignore this hint and provide their own algorithms, or may use this Duration
as provided.
The implementation of std::fmt::Display
for this error will simply pass through the
display of the source message unmodified.
§Examples
use std::time::Duration;
use grid_sdk::error::ResourceTemporarilyUnavailableError;
let io_err = std::io::Error::new(std::io::ErrorKind::Other, "io error");
let rtu_error = ResourceTemporarilyUnavailableError::from_source_with_hint(Box::new(io_err), Duration::new(10, 0));
assert_eq!(format!("{}", rtu_error), "io error");
Sourcepub fn retry_duration_hint(&self) -> Option<Duration>
pub fn retry_duration_hint(&self) -> Option<Duration>
Returns the duration which the underlying library provides as a suggestion for an appropriate amount of time between retry attempts.