types: Time

This commit is contained in:
Mike Dilger committed 2024-02-17 09:49:44 +13:00
1 parent 806d3e5ee0
commit fd24a99c77
2 files changed
+27

No files matched your search

+3
View File
@@ -9,3 +9,6 @@ pub use pubkey::Pubkey;
mod sig;
pub use sig::Sig;
mod time;
pub use time::Time;
+24
View File
@@ -0,0 +1,24 @@
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Time(pub u64);
impl fmt::Display for Time {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl Time {
pub fn as_u64(&self) -> u64 {
self.0
}
pub fn min() -> Time {
Time(0)
}
pub fn max() -> Time {
Time(u64::MAX)
}
}