use std::time::Duration;
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct ClientConfig {
pub max_size: usize,
#[cfg_attr(feature = "serde", serde(default))]
pub timeouts: Timeouts,
}
impl ClientConfig {
#[must_use]
pub fn new(max_size: usize) -> Self {
Self {
max_size,
timeouts: Timeouts::default(),
}
}
}
impl Default for ClientConfig {
fn default() -> Self {
Self::new(1024)
}
}
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Timeouts {
pub wait: Option<Duration>,
pub connect: Option<Duration>,
pub reuse: Option<Duration>,
}
impl Timeouts {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn wait_millis(wait: u64) -> Self {
Self {
connect: None,
wait: Some(Duration::from_millis(wait)),
reuse: None,
}
}
}
impl Default for Timeouts {
fn default() -> Self {
Self {
connect: None,
wait: None,
reuse: None,
}
}
}