sys-resource-manager 0.1.0

A system resource manager displaying system info.
use sysinfo::System;
use eframe::egui;

/// Show Swap Memory Info
pub fn show_swap_info(sys: &System, ui: &mut egui::Ui) {
    let total = sys.total_swap() as f64 / 1024.0 / 1024.0;
    let used = sys.used_swap() as f64 / 1024.0 / 1024.0;

    let (used_val, used_unit) = if used >= 1000.0 {
        (used / 1024.0, "GB")
    } else {
        (used, "MB")
    };

    let (total_val, total_unit) = if total >= 1000.0 {
        (total / 1024.0, "GB")
    } else {
        (total, "MB")
    };

    ui.label(format!(
        "Swap Usage: {:.2} {} / {:.2} {}",
        used_val, used_unit, total_val, total_unit
    ));
    ui.separator();
}