pub trait SleepCapable {
type Duration;
// Required method
fn sleep(&self, duration: Self::Duration) -> impl Future<Output = ()> + Send;
}Expand description
Trait for adapters that support sleep/delay operations
Provides capability to pause execution for a specified duration.
Required Associated Types§
Required Methods§
Sourcefn sleep(&self, duration: Self::Duration) -> impl Future<Output = ()> + Send
fn sleep(&self, duration: Self::Duration) -> impl Future<Output = ()> + Send
Pauses execution for the specified duration without blocking other tasks
§Example
use aimdb_core::time::SleepCapable;
use std::time::Duration;
async fn rate_limited_operation<S: SleepCapable<Duration = Duration>>(
sleeper: &S
) {
println!("Starting operation...");
sleeper.sleep(Duration::from_secs(1)).await;
println!("Operation completed after delay");
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.