Expand description
Timeout policy for time-bounded operations.
The timeout policy ensures operations complete within a specified duration, preventing indefinite hangs.
§Examples
use do_over::{policy::Policy, timeout::TimeoutPolicy, error::DoOverError};
use std::time::Duration;
let policy = TimeoutPolicy::new(Duration::from_secs(5));
match policy.execute(|| async {
// Operation that might hang
Ok::<_, DoOverError<std::io::Error>>("completed")
}).await {
Ok(result) => println!("Success: {}", result),
Err(DoOverError::Timeout) => println!("Operation timed out"),
Err(e) => println!("Error: {:?}", e),
}Structs§
- Timeout
Policy - A policy that enforces a maximum duration for operations.