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 the run method. This type must implement the Debug trait.
  • Error: The type of the error returned by the run method. This type must also implement the Debug trait.

§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));

Required Associated Types§

source

type Item: Debug

The type of the value returned by the run method.

source

type Error: Debug

The type of the error returned by the run method.

Required Methods§

source

fn run(&mut self) -> Result<Self::Item, Self::Error>

Performs the operation and returns the result.

Implementors§

source§

impl<I: Debug, E: Debug, F: FnMut() -> Result<I, E>> SyncReturn for F

§

type Item = I

§

type Error = E