use std::sync::OnceLock;
use std::time::Duration;
fn build(timeout: Option<Duration>) -> reqwest::Client {
let mut builder = reqwest::Client::builder();
if let Some(timeout) = timeout {
builder = builder.timeout(timeout);
}
builder.build().unwrap_or_else(|_| reqwest::Client::new())
}
pub fn shared() -> reqwest::Client {
static CLIENT: OnceLock<reqwest::Client> = OnceLock::new();
CLIENT.get_or_init(|| build(None)).clone()
}
pub fn standard() -> reqwest::Client {
static CLIENT: OnceLock<reqwest::Client> = OnceLock::new();
CLIENT
.get_or_init(|| build(Some(Duration::from_secs(30))))
.clone()
}
pub fn long() -> reqwest::Client {
static CLIENT: OnceLock<reqwest::Client> = OnceLock::new();
CLIENT
.get_or_init(|| build(Some(Duration::from_secs(120))))
.clone()
}