rustftechh 0.1.1

A blazingly fast, highly extensible, and feature-rich system information tool written in Rust with fastfetch parity and multi-distro logos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::ffi;
use crate::info::platform::format_usage_gib;

pub fn detect_memory() -> Option<String> {
    unsafe {
        let mut status = ffi::MEMORYSTATUSEX::zeroed();
        if ffi::GlobalMemoryStatusEx(&mut status) == 0 {
            return None;
        }
        let total = status.ullTotalPhys;
        let avail = status.ullAvailPhys;
        if avail > total {
            return None;
        }
        format_usage_gib(total - avail, total)
    }
}