pub struct BandwidthStats {
pub bytes_uploaded: Bytes,
pub bytes_downloaded: Bytes,
pub chunks_served: u64,
pub chunks_requested: u64,
pub avg_upload_speed_bps: u64,
pub avg_download_speed_bps: u64,
pub peak_upload_speed_bps: u64,
pub peak_download_speed_bps: u64,
pub period_start: DateTime<Utc>,
pub period_end: DateTime<Utc>,
}Expand description
Bandwidth statistics over a time period.
§Examples
use chie_shared::BandwidthStats;
let now = chrono::Utc::now();
let hour_ago = now - chrono::Duration::hours(1);
let stats = BandwidthStats {
bytes_uploaded: 1024 * 1024 * 100, // 100 MB
bytes_downloaded: 1024 * 1024 * 50, // 50 MB
chunks_served: 400,
chunks_requested: 200,
avg_upload_speed_bps: 1024 * 1024, // 1 MB/s
avg_download_speed_bps: 512 * 1024, // 512 KB/s
peak_upload_speed_bps: 5 * 1024 * 1024, // 5 MB/s
peak_download_speed_bps: 2 * 1024 * 1024, // 2 MB/s
period_start: hour_ago,
period_end: now,
};
// Calculate throughput
let total_transfer = stats.bytes_uploaded + stats.bytes_downloaded;
assert!(total_transfer > 0);
// Check chunk efficiency
assert!(stats.chunks_served > stats.chunks_requested);Fields§
§bytes_uploaded: BytesTotal bytes uploaded.
bytes_downloaded: BytesTotal bytes downloaded.
chunks_served: u64Number of chunks served.
chunks_requested: u64Number of chunks requested.
avg_upload_speed_bps: u64Average upload speed (bytes per second).
avg_download_speed_bps: u64Average download speed (bytes per second).
peak_upload_speed_bps: u64Peak upload speed (bytes per second).
peak_download_speed_bps: u64Peak download speed (bytes per second).
period_start: DateTime<Utc>Statistics time range start.
period_end: DateTime<Utc>Statistics time range end.
Trait Implementations§
Source§impl Clone for BandwidthStats
impl Clone for BandwidthStats
Source§fn clone(&self) -> BandwidthStats
fn clone(&self) -> BandwidthStats
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BandwidthStats
impl Debug for BandwidthStats
Source§impl<'de> Deserialize<'de> for BandwidthStats
impl<'de> Deserialize<'de> for BandwidthStats
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BandwidthStats
impl RefUnwindSafe for BandwidthStats
impl Send for BandwidthStats
impl Sync for BandwidthStats
impl Unpin for BandwidthStats
impl UnwindSafe for BandwidthStats
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more