hardware 0.0.7

A no_std bare-metal hardware abstraction layer — all port I/O, memory and swap allocations are guarded at runtime. Do not consider this dependency stable before x.1.x
Documentation
use crate::common::once::OnceCopy;

#[derive(Copy, Clone)]
pub struct MemoryInfo {
    pub total_bytes: u64,
    pub free_bytes: u64,
    pub available_bytes: u64,
    pub swap_total_bytes: u64,
    pub swap_free_bytes: u64,
}

pub type DetectMemoryFn = fn() -> Option<MemoryInfo>;

static DETECT_FN: OnceCopy<DetectMemoryFn> = OnceCopy::new();

pub fn set_detect_memory_fn(f: DetectMemoryFn) {
    DETECT_FN.set(f);
}

pub fn detect_memory_info() -> Option<MemoryInfo> {
    let f = DETECT_FN.get()?;
    f()
}