File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
internal/mithril-dmq/src/model Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 11mod builder;
22mod message;
3+ mod timestamp;
34
45pub use builder:: * ;
56pub use message:: * ;
7+ pub use timestamp:: * ;
Original file line number Diff line number Diff line change 1+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
2+
3+ use mithril_common:: StdResult ;
4+
5+ /// Provides the current timestamp in seconds since the UNIX epoch.
6+ #[ cfg_attr( test, mockall:: automock) ]
7+ pub trait UnixTimestampProvider : Send + Sync {
8+ /// Returns the current timestamp in seconds since the UNIX epoch.
9+ fn current_timestamp ( & self ) -> StdResult < u64 > ;
10+ }
11+
12+ /// Provides the current timestamp in seconds since the UNIX epoch from the system.
13+ pub struct SystemUnixTimestampProvider ;
14+
15+ impl UnixTimestampProvider for SystemUnixTimestampProvider {
16+ fn current_timestamp ( & self ) -> StdResult < u64 > {
17+ Ok ( SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) ?. as_secs ( ) )
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments