openrouter-client 0.2.0

Idiomatic async Rust SDK for the OpenRouter API.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Runtime-neutral sleep support for retry and stream backoff.

use std::time::Duration;

#[cfg(not(target_arch = "wasm32"))]
pub(crate) async fn sleep(duration: Duration) {
    tokio::time::sleep(duration).await;
}

#[cfg(all(target_arch = "wasm32", feature = "browser"))]
pub(crate) async fn sleep(duration: Duration) {
    let millis = duration.as_millis().min(u32::MAX as u128) as u32;
    gloo_timers::future::TimeoutFuture::new(millis).await;
}