ziro 0.0.25

Cross-platform port management tool - quickly find and kill processes occupying ports
Documentation
pub mod icons;
pub mod render;
pub mod theme;

pub use icons::Icons;
pub use render::*;
pub use theme::Theme;

/// Format byte size to human-readable string
pub fn format_size(size: u64) -> String {
    const UNITS: &[&str] = &["B", "KB", "MB", "GB", "TB"];
    let mut size = size as f64;
    let mut unit_index = 0;

    while size >= 1024.0 && unit_index < UNITS.len() - 1 {
        size /= 1024.0;
        unit_index += 1;
    }

    if unit_index == 0 {
        format!("{} {}", size as u64, UNITS[unit_index])
    } else {
        format!("{:.1} {}", size, UNITS[unit_index])
    }
}