teaql-tool-std 0.1.1

Zero-dependency standard utilities for the TeaQL Tool ecosystem.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[derive(Debug, Clone)]
pub struct UnitTool;

impl UnitTool {
    pub fn new() -> Self { Self }

    pub fn bytes_to_kb(&self, bytes: u64) -> f64 { bytes as f64 / 1024.0 }
    pub fn bytes_to_mb(&self, bytes: u64) -> f64 { bytes as f64 / 1024.0 / 1024.0 }
    pub fn bytes_to_gb(&self, bytes: u64) -> f64 { bytes as f64 / 1024.0 / 1024.0 / 1024.0 }
    
    pub fn c_to_f(&self, c: f64) -> f64 { c * 9.0 / 5.0 + 32.0 }
    pub fn f_to_c(&self, f: f64) -> f64 { (f - 32.0) * 5.0 / 9.0 }
}

impl Default for UnitTool {
    fn default() -> Self { Self::new() }
}