use human_units::FormatSize; use std::fmt::{Display, Formatter, Result}; pub trait Human { fn human(&self) -> String; } pub struct Quantity(u64); impl Display for Quantity { fn fmt(&self, f: &mut Formatter<'_>) -> Result { self.0.format_size().fmt(f) } } impl Human for Quantity { fn human(&self) -> String { self.to_string() } } impl Human for u64 { fn human(&self) -> String { self.format_size().to_string() } } impl Human for Option { fn human(&self) -> String { match self { Some(h) => h.human(), None => "◌".to_string(), } } }