Enum retry::OperationResult
source · [−]pub enum OperationResult<T, E> {
Ok(T),
Retry(E),
Err(E),
}
Expand description
A result that represents either success, retryable failure, or immediately-returning failure.
Variants
Ok(T)
Contains the success value.
Retry(E)
Contains the error value if duration is exceeded.
Err(E)
Contains an error value to return immediately.
Implementations
Returns true
if the result is OperationResult::Ok
.
Examples
Basic usage:
let x: OperationResult<i32, &str> = OperationResult::Ok(-3);
assert_eq!(x.is_ok(), true);
let x: OperationResult<i32, &str> = OperationResult::Retry("Some error message");
assert_eq!(x.is_ok(), false);
let x: OperationResult<i32, &str> = OperationResult::Err("Some other error message");
assert_eq!(x.is_ok(), false);
Returns true
if the result is OperationResult::Retry
.
Examples
Basic usage:
let x: OperationResult<i32, &str> = OperationResult::Ok(-3);
assert_eq!(x.is_retry(), false);
let x: OperationResult<i32, &str> = OperationResult::Retry("Some error message");
assert_eq!(x.is_retry(), true);
let x: OperationResult<i32, &str> = OperationResult::Err("Some other error message");
assert_eq!(x.is_retry(), false);
Returns true
if the result is OperationResult::Err
.
Examples
Basic usage:
let x: OperationResult<i32, &str> = OperationResult::Ok(-3);
assert_eq!(x.is_err(), false);
let x: OperationResult<i32, &str> = OperationResult::Retry("Some error message");
assert_eq!(x.is_err(), false);
let x: OperationResult<i32, &str> = OperationResult::Err("Some other error message");
assert_eq!(x.is_err(), true);
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
impl<T: PartialOrd, E: PartialOrd> PartialOrd<OperationResult<T, E>> for OperationResult<T, E>
impl<T: PartialOrd, E: PartialOrd> PartialOrd<OperationResult<T, E>> for OperationResult<T, E>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl<T, E> RefUnwindSafe for OperationResult<T, E> where
E: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, E> Send for OperationResult<T, E> where
E: Send,
T: Send,
impl<T, E> Sync for OperationResult<T, E> where
E: Sync,
T: Sync,
impl<T, E> Unpin for OperationResult<T, E> where
E: Unpin,
T: Unpin,
impl<T, E> UnwindSafe for OperationResult<T, E> where
E: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more