blob: 459464dcbfc3afdca2a5f57440f281bcc438942a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
use heim::units::information;
use std::time::Instant;
#[derive(Debug, Clone)]
pub struct MemData {
pub mem_total_in_mb: u64,
pub mem_used_in_mb: u64,
pub instant: Instant,
}
pub async fn get_mem_data_list() -> crate::utils::error::Result<MemData> {
let memory = heim::memory::memory().await?;
Ok(MemData {
mem_total_in_mb: memory.total().get::<information::megabyte>(),
mem_used_in_mb: memory.total().get::<information::megabyte>() - memory.available().get::<information::megabyte>(),
instant: Instant::now(),
})
}
pub async fn get_swap_data_list() -> crate::utils::error::Result<MemData> {
let memory = heim::memory::swap().await?;
Ok(MemData {
mem_total_in_mb: memory.total().get::<information::megabyte>(),
mem_used_in_mb: memory.used().get::<information::megabyte>(),
instant: Instant::now(),
})
}
|