mod measure;
mod unit_format;
mod unit_simple;
use core::fmt::Debug;
use core::fmt::Display;
use crate::unit_creation::MeasureSystem as MS;
pub use measure::Measure;
use num_traits::{NumOps, One};
pub use unit_format::UnitFormat;
pub use unit_simple::UnitSimple;
pub trait MeasureSystem
where
Self: Sized + PartialEq + PartialOrd,
{
type N: NumTrait;
#[cfg(feature = "str")]
const DEBUG_UNIT: UnitFormat<'static, Self>;
}
pub trait NumTrait: PartialEq + One + NumOps + Clone + Debug + Display {}
impl<U> NumTrait for U where U: PartialEq + One + NumOps + Clone + Debug + Display {}
pub trait MultiplyBy<OTH: MS> {
type Output: MS<N = OTH::N>;
}
pub trait DivideBy<OTH: MS> {
type Output: MS<N = OTH::N>;
}
pub trait UnitTrait {
type System: MS;
fn from(&self, val: <<Self as UnitTrait>::System as MS>::N) -> Measure<Self::System>;
fn to_base(
&self,
val: <<Self as UnitTrait>::System as MS>::N,
) -> <<Self as UnitTrait>::System as MS>::N;
fn to_self(
&self,
val: <<Self as UnitTrait>::System as MS>::N,
) -> <<Self as UnitTrait>::System as MS>::N;
}
#[cfg(feature = "std")]
#[cfg(feature = "str")]
pub trait UnitFormatTrait {
type System: MS;
fn as_string_abbr(&self, val: Measure<Self::System>) -> String;
fn as_string_full(&self, val: Measure<Self::System>) -> String;
}