Struct lightning_invoice::PositiveTimestamp
source · pub struct PositiveTimestamp(_);
Expand description
A timestamp that refers to a date after 1 January 1970.
Invariants
The Unix timestamp representing the stored time has to be positive and no greater than
MAX_TIMESTAMP
.
Implementations§
source§impl PositiveTimestamp
impl PositiveTimestamp
sourcepub fn from_unix_timestamp(unix_seconds: u64) -> Result<Self, CreationError>
pub fn from_unix_timestamp(unix_seconds: u64) -> Result<Self, CreationError>
Creates a PositiveTimestamp
from a Unix timestamp in the range 0..=MAX_TIMESTAMP
.
Otherwise, returns a CreationError::TimestampOutOfBounds
.
sourcepub fn from_system_time(time: SystemTime) -> Result<Self, CreationError>
Available on crate feature std
only.
pub fn from_system_time(time: SystemTime) -> Result<Self, CreationError>
std
only.Creates a PositiveTimestamp
from a SystemTime
with a corresponding Unix timestamp in
the range 0..=MAX_TIMESTAMP
.
Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
Otherwise, returns a CreationError::TimestampOutOfBounds
.
sourcepub fn from_duration_since_epoch(
duration: Duration
) -> Result<Self, CreationError>
pub fn from_duration_since_epoch( duration: Duration ) -> Result<Self, CreationError>
Creates a PositiveTimestamp
from a Duration
since the Unix epoch in the range
0..=MAX_TIMESTAMP
.
Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
Otherwise, returns a CreationError::TimestampOutOfBounds
.
sourcepub fn as_unix_timestamp(&self) -> u64
pub fn as_unix_timestamp(&self) -> u64
Returns the Unix timestamp representing the stored time
sourcepub fn as_duration_since_epoch(&self) -> Duration
pub fn as_duration_since_epoch(&self) -> Duration
Returns the duration of the stored time since the Unix epoch
sourcepub fn as_time(&self) -> SystemTime
Available on crate feature std
only.
pub fn as_time(&self) -> SystemTime
std
only.Returns the SystemTime
representing the stored time
Trait Implementations§
source§impl Clone for PositiveTimestamp
impl Clone for PositiveTimestamp
source§fn clone(&self) -> PositiveTimestamp
fn clone(&self) -> PositiveTimestamp
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PositiveTimestamp
impl Debug for PositiveTimestamp
source§impl From<PositiveTimestamp> for SystemTime
Available on crate feature std
only.
impl From<PositiveTimestamp> for SystemTime
std
only.source§fn from(val: PositiveTimestamp) -> Self
fn from(val: PositiveTimestamp) -> Self
source§impl FromBase32 for PositiveTimestamp
impl FromBase32 for PositiveTimestamp
§type Err = Bolt11ParseError
type Err = Bolt11ParseError
source§impl Hash for PositiveTimestamp
impl Hash for PositiveTimestamp
source§impl Ord for PositiveTimestamp
impl Ord for PositiveTimestamp
source§fn cmp(&self, other: &PositiveTimestamp) -> Ordering
fn cmp(&self, other: &PositiveTimestamp) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<PositiveTimestamp> for PositiveTimestamp
impl PartialEq<PositiveTimestamp> for PositiveTimestamp
source§fn eq(&self, other: &PositiveTimestamp) -> bool
fn eq(&self, other: &PositiveTimestamp) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<PositiveTimestamp> for PositiveTimestamp
impl PartialOrd<PositiveTimestamp> for PositiveTimestamp
source§fn partial_cmp(&self, other: &PositiveTimestamp) -> Option<Ordering>
fn partial_cmp(&self, other: &PositiveTimestamp) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more