File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,24 @@ impl From<MlsTime> for Duration {
60
60
}
61
61
}
62
62
63
+ #[ cfg( all( not( target_arch = "wasm32" ) , feature = "std" ) ) ]
64
+ #[ derive( Debug , thiserror:: Error ) ]
65
+ #[ error( "Overflow while adding {0:?}" ) ]
66
+ /// Overflow in time conversion.
67
+ pub struct TimeOverflow ( Duration ) ;
68
+
69
+ #[ cfg( all( not( target_arch = "wasm32" ) , feature = "std" ) ) ]
70
+ impl TryFrom < MlsTime > for std:: time:: SystemTime {
71
+ type Error = TimeOverflow ;
72
+
73
+ fn try_from ( value : MlsTime ) -> Result < std:: time:: SystemTime , Self :: Error > {
74
+ let duration = Duration :: from ( value) ;
75
+ std:: time:: SystemTime :: UNIX_EPOCH
76
+ . checked_add ( duration)
77
+ . ok_or ( TimeOverflow ( duration) )
78
+ }
79
+ }
80
+
63
81
#[ cfg( all( not( target_arch = "wasm32" ) , feature = "std" ) ) ]
64
82
impl TryFrom < std:: time:: SystemTime > for MlsTime {
65
83
type Error = std:: time:: SystemTimeError ;
You can’t perform that action at this time.
0 commit comments