pub struct Timestamp(pub i64);Expand description
A Unix timestamp in seconds.
AITP timestamps are integers — never floats. This newtype enforces that at the type level: it serializes and deserializes as a JSON integer.
Tuple Fields§
§0: i64Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn is_within_tolerance_of(
self,
reference: Timestamp,
tolerance_secs: i64,
) -> bool
pub fn is_within_tolerance_of( self, reference: Timestamp, tolerance_secs: i64, ) -> bool
True if self is within ±tolerance seconds of reference.
self.0 is deserialized verbatim from the wire, so the difference
is computed with checked_sub + unsigned_abs to avoid an i64
overflow (e.g. i64::MIN - reference, or i64::MIN.abs()) on
attacker-controlled extremes — a debug panic / release wraparound.
A negative tolerance_secs is treated as zero tolerance.
Sourcepub fn is_fresh(self, reference: Timestamp) -> bool
pub fn is_fresh(self, reference: Timestamp) -> bool
True if self is within the default ±300s window of reference.
Sourcepub fn is_in_the_past(self, reference: Timestamp) -> bool
pub fn is_in_the_past(self, reference: Timestamp) -> bool
True if self is in the past (relative to reference).
Sourcepub fn is_in_the_future(self, reference: Timestamp) -> bool
pub fn is_in_the_future(self, reference: Timestamp) -> bool
True if self is in the future (relative to reference).
Trait Implementations§
impl Copy for Timestamp
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Timestamp
Source§impl Ord for Timestamp
impl Ord for Timestamp
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnsafeUnpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.