mirror of
https://github.com/mikedilger/chorus.git
synced 2026-08-01 07:21:39 +00:00
types: Time
This commit is contained in:
parent
806d3e5ee0
commit
fd24a99c77
@ -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
24
src/types/time.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user