#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PeerStatus {
Active,
Idle,
}
#[derive(Debug, Clone)]
pub struct PeerStat {
pub cuid: u64,
pub download_speed: u64,
pub avg_download_speed: u64,
pub session_download_length: u64,
pub hostname: String,
pub protocol: String,
pub status: PeerStatus,
}
impl PeerStat {
pub fn new(cuid: u64, hostname: String, protocol: String) -> Self {
PeerStat {
cuid,
download_speed: 0,
avg_download_speed: 0,
session_download_length: 0,
hostname,
protocol,
status: PeerStatus::Idle,
}
}
pub fn add_session_download_length(&mut self, length: u64) {
self.session_download_length = self.session_download_length.saturating_add(length);
}
}