use std::time::Duration;
macro_rules! zdebug {
($($t:tt)*) => {
#[cfg(feature = "tracing")]
tracing::debug!($($t)*);
};
}
macro_rules! zwarn {
($($t:tt)*) => {
#[cfg(feature = "tracing")]
tracing::warn!($($t)*);
};
}
pub(crate) use {zdebug, zwarn};
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct TransferStats {
pub bytes_fetched: u64,
pub chunks_fetched: u32,
pub chunks_resumed: u32,
pub rejected: u32,
pub retries: u32,
pub elapsed: Duration,
}
impl TransferStats {
pub fn throughput_bps(&self) -> u64 {
let secs = self.elapsed.as_secs_f64();
if secs <= f64::EPSILON {
return 0;
}
(self.bytes_fetched as f64 / secs) as u64
}
}