pub struct PositiveTimestamp(_);
A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX
timestamp is positive.
The UNIX timestamp representing the stored time has to be positive and small enough so that
a EpiryTime
can be added to it without an overflow.
Create a new PositiveTimestamp
from a unix timestamp in the Range
0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME
, otherwise return a
CreationError::TimestampOutOfBounds
.
Create a new PositiveTimestamp
from a SystemTime
with a corresponding unix timestamp in
the Range 0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME
, otherwise return a
CreationError::TimestampOutOfBounds
.
Returns the UNIX timestamp representing the stored time
Returns a reference to the internal SystemTime
time representation
Returns the amount of time elapsed from an earlier point in time.
This function may fail because measurements taken earlier are not
guaranteed to always be before later measurements (due to anomalies such
as the system clock being adjusted either forwards or backwards).
If successful, Ok
(
Duration
)
is returned where the duration represents
the amount of time elapsed from the specified measurement to this one.
Returns an Err
if earlier
is later than self
, and the error
contains how far from self
the time is.
use std::time::SystemTime;
let sys_time = SystemTime::now();
let difference = sys_time.duration_since(sys_time)
.expect("SystemTime::duration_since failed");
println!("{:?}", difference);
Returns the amount of time elapsed since this system time was created.
This function may fail as the underlying system clock is susceptible to
drift and updates (e.g., the system clock could go backwards), so this
function may not always succeed. If successful, Ok
(
Duration
)
is
returned where the duration represents the amount of time elapsed from
this time measurement to the current time.
Returns an Err
if self
is later than the current system time, and
the error contains how far from the current system time self
is.
use std::thread::sleep;
use std::time::{Duration, SystemTime};
let sys_time = SystemTime::now();
let one_sec = Duration::from_secs(1);
sleep(one_sec);
assert!(sys_time.elapsed().unwrap() >= one_sec);
🔬 This is a nightly-only experimental API. (time_checked_add
)
Returns Some(t)
where t
is the time self + duration
if t
can be represented as
SystemTime
(which means it's inside the bounds of the underlying data structure), None
otherwise.
🔬 This is a nightly-only experimental API. (time_checked_add
)
Returns Some(t)
where t
is the time self - duration
if t
can be represented as
SystemTime
(which means it's inside the bounds of the underlying data structure), None
otherwise.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
The associated error which can be returned from parsing (e.g. because of bad padding).
Convert a base32 slice to Self
.
Convert Self
to base32 slice
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Convert base256 to base32, adds padding if necessary