gnss_qc_traits/processing/time/mod.rs
1use thiserror::Error;
2
3mod correction;
4pub use correction::TimeCorrection;
5
6mod database;
7pub use database::TimeCorrectionsDB;
8
9use hifitime::TimeScale;
10
11/// [TimeCorrectionError] returned by precise correction methods.
12#[derive(Debug, Error)]
13pub enum TimeCorrectionError {
14 #[error("no correction available for {0}/{1}")]
15 NoCorrectionAvailable(TimeScale, TimeScale),
16}
17
18/// The [Timeshift] trait allows transposition to different [TimeScale]s and precise stirring.
19pub trait Timeshift {
20 /// Temporal transposition to desired [TimeScale], without mutable access.
21 /// The difference between this method and [Self::precise_correction] is that
22 /// it cannot take the _actual_ [TimeScale] states into account.
23 fn timeshift(&self, timescale: TimeScale) -> Self
24 where
25 Self: Sized;
26
27 /// Temporal transposition to desired [TimeScale], without mutable access.
28 /// The difference between this method and [Self::precise_correction] is that
29 /// it cannot take the _actual_ [TimeScale] states into account.
30 fn timeshift_mut(&mut self, timescale: TimeScale);
31
32 /// Precise stirring to desired [TimeScale], without mutable access.
33 /// The difference between this method and [Self::timeshift] is that this
34 /// method takes the _actual_ [TimeScale] states into account.
35 fn precise_correction(
36 &self,
37 db: &TimeCorrectionsDB,
38 target: TimeScale,
39 ) -> Result<Self, TimeCorrectionError>
40 where
41 Self: Sized;
42
43 /// Precise stirring to desired [TimeScale], with mutable access.
44 /// The difference between this method and [Self::timeshift_mut] is that this
45 /// method takes the _actual_ [TimeScale] states into account.
46 fn precise_correction_mut(
47 &mut self,
48 db: &TimeCorrectionsDB,
49 target: TimeScale,
50 ) -> Result<(), TimeCorrectionError>;
51}