use super::sealed::Sealed;
pub(crate) mod conversion;
#[allow(private_bounds)]
pub trait Scale: Sealed + Copy + Clone + core::fmt::Debug + 'static {
const NAME: &'static str;
}
macro_rules! define_continuous_scale {
($(#[$meta:meta])* $ident:ident = $name:literal) => {
$(#[$meta])*
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct $ident;
impl Sealed for $ident {}
impl Scale for $ident {
const NAME: &'static str = $name;
}
};
}
macro_rules! define_civil_scale {
($(#[$meta:meta])* $ident:ident = $name:literal) => {
$(#[$meta])*
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct $ident;
impl Sealed for $ident {}
impl Scale for $ident {
const NAME: &'static str = $name;
}
};
}
define_civil_scale!(
UTC = "UTC"
);
define_continuous_scale!(
TAI = "TAI"
);
define_continuous_scale!(
TT = "TT"
);
define_continuous_scale!(
TDB = "TDB"
);
define_continuous_scale!(
TCG = "TCG"
);
define_continuous_scale!(
TCB = "TCB"
);
define_continuous_scale!(
UT1 = "UT1"
);
#[allow(private_bounds)]
pub trait CoordinateScale: Scale + Sealed {}
macro_rules! coordinate {
($($scale:ty),+ $(,)?) => {
$(impl CoordinateScale for $scale {})+
};
}
coordinate!(TAI, TT, TDB, TCG, TCB, UT1, UTC);
#[allow(private_bounds)]
pub trait ContinuousScale: CoordinateScale + Sealed {}
macro_rules! continuous {
($($scale:ty),+ $(,)?) => {
$(impl ContinuousScale for $scale {})+
};
}
continuous!(TAI, TT, TDB, TCG, TCB, UT1);