substrate_stellar_sdk/xdr/impls/
time_bounds.rs

1use crate::TimeBounds;
2
3pub trait IntoTimePoint {
4    fn into_time_point(self) -> u64;
5}
6
7pub struct MilliSecondEpochTime(pub u64);
8pub struct SecondEpochTime(pub u64);
9
10impl IntoTimePoint for MilliSecondEpochTime {
11    fn into_time_point(self) -> u64 {
12        self.0 / 1000
13    }
14}
15
16impl IntoTimePoint for SecondEpochTime {
17    fn into_time_point(self) -> u64 {
18        self.0
19    }
20}
21
22impl IntoTimePoint for () {
23    fn into_time_point(self) -> u64 {
24        0
25    }
26}
27
28impl TimeBounds {
29    pub fn from_time_points<T: IntoTimePoint, S: IntoTimePoint>(min_time: T, max_time: S) -> TimeBounds {
30        TimeBounds { min_time: min_time.into_time_point(), max_time: max_time.into_time_point() }
31    }
32}