tokio_retry/
action.rs

1use std::future::Future;
2
3/// An action can be run multiple times and produces a future.
4pub trait Action {
5    /// The future that this action produces.
6    type Future: Future<Output = Result<Self::Item, Self::Error>>;
7    /// The item that the future may resolve with.
8    type Item;
9    /// The error that the future may resolve with.
10    type Error;
11
12    fn run(&mut self) -> Self::Future;
13}
14
15impl<R, E, T: Future<Output = Result<R, E>>, F: FnMut() -> T> Action for F {
16    type Item = R;
17    type Error = E;
18    type Future = T;
19
20    fn run(&mut self) -> Self::Future {
21        self()
22    }
23}