blob: c7c06f8d10e29e76bd1a1513ad3fa86f011ce068 (
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_common::units::information;
use std::time::Instant;
#[derive(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() -> Result<MemData, heim::Error> {
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() -> Result<MemData, heim::Error> {
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(),
})
}
|