Struct lightning_invoice::PositiveTimestamp
source · pub struct PositiveTimestamp(/* private fields */);
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 Duration
impl From<PositiveTimestamp> for Duration
source§fn from(val: PositiveTimestamp) -> Self
fn from(val: PositiveTimestamp) -> Self
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
source§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 for PositiveTimestamp
impl PartialEq for PositiveTimestamp
source§impl PartialOrd for PositiveTimestamp
impl PartialOrd for PositiveTimestamp
source§impl ToBase32 for PositiveTimestamp
impl ToBase32 for PositiveTimestamp
source§fn write_base32<W: WriteBase32>(
&self,
writer: &mut W,
) -> Result<(), <W as WriteBase32>::Err>
fn write_base32<W: WriteBase32>( &self, writer: &mut W, ) -> Result<(), <W as WriteBase32>::Err>
impl Eq for PositiveTimestamp
impl StructuralPartialEq for PositiveTimestamp
Auto Trait Implementations§
impl Freeze for PositiveTimestamp
impl RefUnwindSafe for PositiveTimestamp
impl Send for PositiveTimestamp
impl Sync for PositiveTimestamp
impl Unpin for PositiveTimestamp
impl UnwindSafe for PositiveTimestamp
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)