suno_core/clock.rs
1//! The clock port: the executor's only source of delay.
2//!
3//! The download executor waits in two places: between polls for a server-side
4//! WAV render, and as backoff after a rate-limit or transient failure. Both go
5//! through this trait so the wait is injected, never taken from the wall clock.
6//! The CLI adapter sleeps with the async runtime; tests use a double that
7//! returns immediately and records the requested delays, keeping every test
8//! deterministic with no real sleeping.
9
10use std::future::Future;
11use std::time::Duration;
12
13/// The delay port the executor waits through.
14pub trait Clock {
15 /// Wait for `duration`, then resolve.
16 fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + Send;
17}