Changing println to proper log macros and small fixes.

This commit is contained in:
2026-05-26 17:56:02 +02:00
parent e0c6112422
commit 6b4550dc8e
10 changed files with 104 additions and 117 deletions
+2 -21
View File
@@ -20,25 +20,6 @@
use std::ops::{Add, Sub};
pub fn format_bytes_size(size: u64) -> String {
let suffixs: [&str; 5] = ["KB", "MB", "GB", "TB", "PB"];
if size < 1000 {
format!("{}B", size)
} else {
let mut s = size as f64;
let mut idx = 0;
for i in 0..5 {
s = s / 1024.0;
idx = i;
if s < 1000.0 {
break;
}
}
format!("{:.2}{}", s, suffixs[idx])
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct KiraSize {
size_bytes: u64,
@@ -65,7 +46,7 @@ impl std::fmt::Display for KiraSize {
impl KiraSize {
pub const SUFFIXS: [&str; 5] = ["KB", "MB", "GB", "TB", "PB"];
pub fn new(size:u64) -> Self {
pub fn new_b(size:u64) -> Self {
Self { size_bytes: size }
}
pub fn new_kb(size:u64) -> Self {
@@ -104,7 +85,7 @@ impl KiraSize {
}
pub fn from_str_bytes(s: &str) -> Option<Self> {
Some(Self::new(u64::from_str_radix(s, 10).ok()?))
Some(Self::new_b(u64::from_str_radix(s, 10).ok()?))
}
pub fn div_c(self, other: u64) -> Self {