types: Time

This commit is contained in:
Mike Dilger 2023-11-23 08:58:18 +13:00
parent 806d3e5ee0
commit fd24a99c77
2 changed files with 27 additions and 0 deletions

View File

@ -9,3 +9,6 @@ pub use pubkey::Pubkey;
mod sig;
pub use sig::Sig;
mod time;
pub use time::Time;

24
src/types/time.rs Normal file
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)
}
}