use generic_array::{typenum::U9, ArrayLength, GenericArray};
pub trait DecimalSeparator {
const SEPARATOR: char;
}
pub struct CommaSeparated;
impl DecimalSeparator for CommaSeparated {
const SEPARATOR: char = ',';
}
pub struct PointSeparated;
impl DecimalSeparator for PointSeparated {
const SEPARATOR: char = '.';
}
pub trait PrefixType {
type N: ArrayLength<&'static str>;
const PREFIX_SIZE: u32;
fn prefixes() -> GenericArray<&'static str, Self::N>;
}
pub struct SIPrefixes;
impl PrefixType for SIPrefixes {
type N = U9;
const PREFIX_SIZE: u32 = 1000;
fn prefixes() -> GenericArray<&'static str, Self::N> {
["", "k", "M", "G", "T", "P", "E", "Z", "Y"].into()
}
}
pub struct BinaryPrefixes;
impl PrefixType for BinaryPrefixes {
type N = U9;
const PREFIX_SIZE: u32 = 1024;
fn prefixes() -> GenericArray<&'static str, Self::N> {
["", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi"].into()
}
}