tempoch_core/format/
traits.rs1use crate::earth::context::TimeContext;
7use crate::format::TimeFormat;
8use crate::foundation::error::ConversionError;
9use crate::foundation::sealed::Sealed;
10use crate::model::scale::Scale;
11use crate::model::time::Time;
12use qtty::Quantity;
13
14#[allow(private_bounds)]
16pub trait FormatForScale<S: Scale>: TimeFormat + Sealed {
17 fn try_from_time<Fin: TimeFormat>(
18 time: Time<S, Fin>,
19 ctx: &TimeContext,
20 ) -> Result<Quantity<Self::Unit>, ConversionError>;
21 fn try_into_time(
22 raw: Quantity<Self::Unit>,
23 ctx: &TimeContext,
24 ) -> Result<Time<S, Self>, ConversionError>
25 where
26 Self: Sized;
27}
28
29#[allow(private_bounds)]
31pub trait InfallibleFormatForScale<S: Scale>: FormatForScale<S> + Sealed {
32 fn from_time<Fin: TimeFormat>(time: Time<S, Fin>) -> Quantity<Self::Unit>;
33 fn into_time(raw: Quantity<Self::Unit>) -> Time<S, Self>;
34}