pub struct RetryError<E> { /* private fields */ }
Expand description
An error type for use when we’re going to do something a few times, and they might all fail.
To use this error type, initialize a new RetryError before you
start trying to do whatever it is. Then, every time the operation
fails, use RetryError::push()
to add a new error to the list
of errors. If the operation fails too many times, you can use
RetryError as an Error
itself.
Implementations§
Source§impl<E> RetryError<E>
impl<E> RetryError<E>
Sourcepub fn in_attempt_to<T: Into<String>>(doing: T) -> Self
pub fn in_attempt_to<T: Into<String>>(doing: T) -> Self
Create a new RetryError, with no failed attempts.
The provided doing
argument is a short string that describes
what we were trying to do when we failed too many times. It
will be used to format the final error message; it should be a
phrase that can go after “while trying to”.
This RetryError should not be used as-is, since when no
Error
s have been pushed into it, it doesn’t represent an
actual failure.
Sourcepub fn push<T>(&mut self, err: T)where
T: Into<E>,
pub fn push<T>(&mut self, err: T)where
T: Into<E>,
Add an error to this RetryError.
You should call this method when an attempt at the underlying operation has failed.
Trait Implementations§
Source§impl<E: Clone> Clone for RetryError<E>
impl<E: Clone> Clone for RetryError<E>
Source§fn clone(&self) -> RetryError<E>
fn clone(&self) -> RetryError<E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<E: Debug> Debug for RetryError<E>
impl<E: Debug> Debug for RetryError<E>
Source§impl<E: Debug + AsRef<dyn Error>> Error for RetryError<E>
impl<E: Debug + AsRef<dyn Error>> Error for RetryError<E>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl<E, T> Extend<T> for RetryError<E>where
T: Into<E>,
impl<E, T> Extend<T> for RetryError<E>where
T: Into<E>,
Source§fn extend<C>(&mut self, iter: C)where
C: IntoIterator<Item = T>,
fn extend<C>(&mut self, iter: C)where
C: IntoIterator<Item = T>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Auto Trait Implementations§
impl<E> Freeze for RetryError<E>
impl<E> RefUnwindSafe for RetryError<E>where
E: RefUnwindSafe,
impl<E> Send for RetryError<E>where
E: Send,
impl<E> Sync for RetryError<E>where
E: Sync,
impl<E> Unpin for RetryError<E>where
E: Unpin,
impl<E> UnwindSafe for RetryError<E>where
E: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 56 bytes