use sys::{Component, Disk, DiskType, NetworkData, Process, Processor};
use Pid;
use ProcessStatus;
use std::collections::HashMap;
use std::ffi::OsStr;
use std::path::Path;
pub trait DiskExt {
fn get_type(&self) -> DiskType;
fn get_name(&self) -> &OsStr;
fn get_file_system(&self) -> &[u8];
fn get_mount_point(&self) -> &Path;
fn get_total_space(&self) -> u64;
fn get_available_space(&self) -> u64;
fn update(&mut self) -> bool;
}
pub trait ProcessExt {
fn new(pid: Pid, parent: Option<Pid>, start_time: u64) -> Self;
fn kill(&self, signal: ::Signal) -> bool;
fn name(&self) -> &str;
fn cmd(&self) -> &[String];
fn exe(&self) -> &Path;
fn pid(&self) -> Pid;
fn environ(&self) -> &[String];
fn cwd(&self) -> &Path;
fn root(&self) -> &Path;
fn memory(&self) -> u64;
fn parent(&self) -> Option<Pid>;
fn status(&self) -> ProcessStatus;
fn start_time(&self) -> u64;
fn cpu_usage(&self) -> f32;
}
pub trait ProcessorExt {
fn get_cpu_usage(&self) -> f32;
fn get_name(&self) -> &str;
}
pub trait SystemExt {
fn new() -> Self;
fn refresh_system(&mut self);
fn refresh_processes(&mut self);
fn refresh_process(&mut self, pid: Pid) -> bool;
fn refresh_disks(&mut self);
fn refresh_disk_list(&mut self);
fn refresh_network(&mut self);
fn refresh_all(&mut self) {
self.refresh_system();
self.refresh_processes();
self.refresh_disks();
self.refresh_network();
}
fn get_process_list(&self) -> &HashMap<Pid, Process>;
fn get_process(&self, pid: Pid) -> Option<&Process>;
fn get_process_by_name(&self, name: &str) -> Vec<&Process> {
let mut ret = vec!();
for val in self.get_process_list().values() {
if val.name().contains(name) {
ret.push(val);
}
}
ret
}
fn get_processor_list(&self) -> &[Processor];
fn get_total_memory(&self) -> u64;
fn get_free_memory(&self) -> u64;
fn get_used_memory(&self) -> u64;
fn get_total_swap(&self) -> u64;
fn get_free_swap(&self) -> u64;
fn get_used_swap(&self) -> u64;
fn get_components_list(&self) -> &[Component];
fn get_disks(&self) -> &[Disk];
fn get_network(&self) -> &NetworkData;
fn get_uptime(&self) -> u64;
}
pub trait NetworkExt {
fn get_income(&self) -> u64;
fn get_outcome(&self) -> u64;
}
pub trait ComponentExt {
fn get_temperature(&self) -> f32;
fn get_max(&self) -> f32;
fn get_critical(&self) -> Option<f32>;
fn get_label(&self) -> &str;
}