pub trait SyncReturn {
type Item: Debug;
type Error: Debug;
// Required method
fn run(&mut self) -> Result<Self::Item, Self::Error>;
}Expand description
The SyncReturn trait is used for operations that need to return a value synchronously.
This trait provides a single method, run, which takes no arguments and returns a Result with the operation’s result or error. Both the result and error types must implement the Debug trait.
§Type Parameters
Item: The type of the value returned by therunmethod. This type must implement theDebugtrait.Error: The type of the error returned by therunmethod. This type must also implement theDebugtrait.
§Methods
run: Performs the operation and returns the result.
§Errors
If the operation fails, this method returns Err containing the error. The type of the error is defined by the Error associated type.
§Examples
use easy_retry::SyncReturn;
use std::fmt::Debug;
struct MyOperation;
impl SyncReturn for MyOperation {
type Item = i32;
type Error = &'static str;
fn run(&mut self) -> Result<Self::Item, Self::Error> {
// Perform the operation and return the result...
Ok(42)
}
}
let mut operation = MyOperation;
assert_eq!(operation.run(), Ok(42));