pub async fn retry<T, E, F, Fut>(
operation: F,
max_attempts: usize,
delay: Duration,
) -> Result<T, E>
Expand description
Attempts to execute a fallible operation multiple times before giving up.
ยงExamples
use neo3::prelude::*;
use neo3::neo_utils::error::retry;
use std::time::Duration;
async fn fallible_operation() -> Result<u32, NeoError> {
// Some operation that might fail
Ok(42)
}
let result = retry(
|| async { fallible_operation().await },
3,
Duration::from_millis(100)
).await;