#[repr(transparent)]pub struct Timestamp<T = u128>(pub T);
Expand description
Timestamp
is a generic implementation of a type that represents some point in time.
§Basic Usage
use scsys_time::Timestamp;
let ts = Timestamp::<u128>::now();
println!("Current Timestamp: {}", ts);
§Features
The timestamps implementation dynamically reflects the extensive feature-gating of the
crate. Listed below are the features that customize the behavior of the Timestamp
type:
Tuple Fields§
§0: T
Implementations§
Source§impl<T> Timestamp<T>where
T: RawTimestamp,
impl<T> Timestamp<T>where
T: RawTimestamp,
Sourcepub fn now() -> Selfwhere
T: Now<Output = Self>,
pub fn now() -> Selfwhere
T: Now<Output = Self>,
a convenience method to get the current timestamp; requires that the inner type
implement the Now
trait.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
consumes the current instance and returns the inner value.
Sourcepub const fn replace(&mut self, value: T) -> T
pub const fn replace(&mut self, value: T) -> T
replace
the current value with a new one and return the old one
Sourcepub fn set(&mut self, ts: T)
pub fn set(&mut self, ts: T)
update the current value and return a mutable reference to the current instance.
Sourcepub const fn swap(&mut self, ts: &mut T)
pub const fn swap(&mut self, ts: &mut T)
swap
the current value with another and return a mutable reference to self
Sourcepub fn with<U: RawTimestamp>(self, ts: U) -> Timestamp<U>
pub fn with<U: RawTimestamp>(self, ts: U) -> Timestamp<U>
consumes the current instance to create another with the given value
Sourcepub fn map<U, F>(self, f: F) -> Timestamp<U>where
F: FnOnce(T) -> U,
U: RawTimestamp,
pub fn map<U, F>(self, f: F) -> Timestamp<U>where
F: FnOnce(T) -> U,
U: RawTimestamp,
applies a function onto the current value and returns a new instance with the result
Sourcepub fn map_inplace<F>(&mut self, f: F) -> &mut Self
pub fn map_inplace<F>(&mut self, f: F) -> &mut Self
returns a new instance of the Timestamp
with the current value updated using the given function
Sourcepub fn update(&mut self) -> Twhere
T: Now<Output = T>,
pub fn update(&mut self) -> Twhere
T: Now<Output = T>,
updates the timestamp to reflect now and return the previous timestamp