11use std:: num:: IntErrorKind ;
22pub use std:: time:: Duration ;
33
4- pub type SinceUnixEpoch = Duration ;
4+ pub type DurationSinceUnixEpoch = Duration ;
55
66#[ derive( Debug ) ]
77pub enum ClockType {
@@ -22,14 +22,14 @@ pub type DefaultClock = WorkingClock;
2222pub type DefaultClock = StoppedClock ;
2323
2424pub trait Time : Sized {
25- fn now ( ) -> SinceUnixEpoch ;
25+ fn now ( ) -> DurationSinceUnixEpoch ;
2626}
2727
2828pub trait TimeNow : Time {
29- fn add ( add_time : & Duration ) -> Option < SinceUnixEpoch > {
29+ fn add ( add_time : & Duration ) -> Option < DurationSinceUnixEpoch > {
3030 Self :: now ( ) . checked_add ( * add_time)
3131 }
32- fn sub ( sub_time : & Duration ) -> Option < SinceUnixEpoch > {
32+ fn sub ( sub_time : & Duration ) -> Option < DurationSinceUnixEpoch > {
3333 Self :: now ( ) . checked_sub ( * sub_time)
3434 }
3535}
@@ -57,10 +57,10 @@ mod tests {
5757mod working_clock {
5858 use std:: time:: SystemTime ;
5959
60- use super :: { SinceUnixEpoch , Time , TimeNow , WorkingClock } ;
60+ use super :: { DurationSinceUnixEpoch , Time , TimeNow , WorkingClock } ;
6161
6262 impl Time for WorkingClock {
63- fn now ( ) -> SinceUnixEpoch {
63+ fn now ( ) -> DurationSinceUnixEpoch {
6464 SystemTime :: now ( ) . duration_since ( SystemTime :: UNIX_EPOCH ) . unwrap ( )
6565 }
6666 }
@@ -69,9 +69,9 @@ mod working_clock {
6969}
7070
7171pub trait StoppedTime : TimeNow {
72- fn local_set ( unix_time : & SinceUnixEpoch ) ;
72+ fn local_set ( unix_time : & DurationSinceUnixEpoch ) ;
7373 fn local_set_to_unix_epoch ( ) {
74- Self :: local_set ( & SinceUnixEpoch :: ZERO )
74+ Self :: local_set ( & DurationSinceUnixEpoch :: ZERO )
7575 }
7676 fn local_set_to_app_start_time ( ) ;
7777 fn local_set_to_system_time_now ( ) ;
@@ -84,10 +84,10 @@ mod stopped_clock {
8484 use std:: num:: IntErrorKind ;
8585 use std:: time:: Duration ;
8686
87- use super :: { SinceUnixEpoch , StoppedClock , StoppedTime , Time , TimeNow } ;
87+ use super :: { DurationSinceUnixEpoch , StoppedClock , StoppedTime , Time , TimeNow } ;
8888
8989 impl Time for StoppedClock {
90- fn now ( ) -> SinceUnixEpoch {
90+ fn now ( ) -> DurationSinceUnixEpoch {
9191 detail:: FIXED_TIME . with ( |time| {
9292 return * time. borrow ( ) ;
9393 } )
@@ -97,7 +97,7 @@ mod stopped_clock {
9797 impl TimeNow for StoppedClock { }
9898
9999 impl StoppedTime for StoppedClock {
100- fn local_set ( unix_time : & SinceUnixEpoch ) {
100+ fn local_set ( unix_time : & DurationSinceUnixEpoch ) {
101101 detail:: FIXED_TIME . with ( |time| {
102102 * time. borrow_mut ( ) = * unix_time;
103103 } )
@@ -147,11 +147,11 @@ mod stopped_clock {
147147 use std:: thread;
148148 use std:: time:: Duration ;
149149
150- use crate :: protocol:: clock:: clock:: { SinceUnixEpoch , StoppedClock , StoppedTime , Time , TimeNow , WorkingClock } ;
150+ use crate :: protocol:: clock:: clock:: { DurationSinceUnixEpoch , StoppedClock , StoppedTime , Time , TimeNow , WorkingClock } ;
151151
152152 #[ test]
153153 fn it_should_default_to_zero_when_testing ( ) {
154- assert_eq ! ( StoppedClock :: now( ) , SinceUnixEpoch :: ZERO )
154+ assert_eq ! ( StoppedClock :: now( ) , DurationSinceUnixEpoch :: ZERO )
155155 }
156156
157157 #[ test]
@@ -206,26 +206,26 @@ mod stopped_clock {
206206 use std:: cell:: RefCell ;
207207 use std:: time:: SystemTime ;
208208
209- use crate :: protocol:: clock:: clock:: SinceUnixEpoch ;
209+ use crate :: protocol:: clock:: clock:: DurationSinceUnixEpoch ;
210210 use crate :: static_time;
211211
212- pub fn get_app_start_time ( ) -> SinceUnixEpoch {
212+ pub fn get_app_start_time ( ) -> DurationSinceUnixEpoch {
213213 ( * static_time:: TIME_AT_APP_START )
214214 . duration_since ( SystemTime :: UNIX_EPOCH )
215215 . unwrap ( )
216216 }
217217
218218 #[ cfg( not( test) ) ]
219- pub fn get_default_fixed_time ( ) -> SinceUnixEpoch {
219+ pub fn get_default_fixed_time ( ) -> DurationSinceUnixEpoch {
220220 get_app_start_time ( )
221221 }
222222
223223 #[ cfg( test) ]
224- pub fn get_default_fixed_time ( ) -> SinceUnixEpoch {
225- SinceUnixEpoch :: ZERO
224+ pub fn get_default_fixed_time ( ) -> DurationSinceUnixEpoch {
225+ DurationSinceUnixEpoch :: ZERO
226226 }
227227
228- thread_local ! ( pub static FIXED_TIME : RefCell <SinceUnixEpoch > = RefCell :: new( get_default_fixed_time( ) ) ) ;
228+ thread_local ! ( pub static FIXED_TIME : RefCell <DurationSinceUnixEpoch > = RefCell :: new( get_default_fixed_time( ) ) ) ;
229229
230230 #[ cfg( test) ]
231231 mod tests {
0 commit comments