mem.rs 364 B

1234567891011121314151617
  1. use systemstat::{saturating_sub_bytes, Platform, System};
  2. use crate::block::Block;
  3. pub struct Mem {}
  4. impl Block for Mem {
  5. fn display(&self) -> String {
  6. let sys = System::new();
  7. if let Ok(mem) = sys.memory() {
  8. format!("{}", saturating_sub_bytes(mem.total, mem.free))
  9. } else {
  10. "".to_string()
  11. }
  12. }
  13. }