Working remote print integration

This commit is contained in:
Connor Slade
2024-07-25 02:35:55 -04:00
parent 0c335bf605
commit c2444b8821
10 changed files with 175 additions and 56 deletions

View File

@@ -5,3 +5,4 @@ edition = "2021"
[dependencies]
nalgebra.workspace = true
rand.workspace = true

View File

@@ -1,5 +1,7 @@
use std::time::Duration;
use rand::{distributions::Alphanumeric, Rng};
use crate::config::SliceConfig;
pub struct SliceResult<'a, Layer> {
@@ -26,9 +28,27 @@ pub fn human_duration(duration: Duration) -> String {
format!("{:}ms", ms)
} else if ms < 60_000.0 {
format!("{:.2}s", ms / 1000.0)
} else {
} else if ms < 3_600_000.0 {
let minutes = ms / 60_000.0;
let seconds = (minutes - minutes.floor()) * 60.0;
format!("{:.0}m {:.2}s", minutes.floor(), seconds)
} else {
let hours = ms / 3_600_000.0;
let minutes = (hours - hours.floor()) * 60.0;
let seconds = (minutes - minutes.floor()) * 60.0;
format!(
"{:.0}h {:.0}m {:.2}s",
hours.floor(),
minutes.floor(),
seconds
)
}
}
pub fn random_string(len: usize) -> String {
rand::thread_rng()
.sample_iter(&Alphanumeric)
.take(len)
.map(char::from)
.collect()
}