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
sourceimpl 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>
This is supported 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
.
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
.
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
This is supported on crate feature std
only.
pub fn as_time(&self) -> SystemTime
std
only.Returns the SystemTime
representing the stored time
Trait Implementations
sourceimpl Clone for PositiveTimestamp
impl Clone for PositiveTimestamp
sourcefn clone(&self) -> PositiveTimestamp
fn clone(&self) -> PositiveTimestamp
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PositiveTimestamp
impl Debug for PositiveTimestamp
sourceimpl FromBase32 for PositiveTimestamp
impl FromBase32 for PositiveTimestamp
type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing (e.g. because of bad padding).
sourceimpl Into<SystemTime> for PositiveTimestamp
This is supported on crate feature std
only.
impl Into<SystemTime> for PositiveTimestamp
std
only.sourcefn into(self) -> SystemTime
fn into(self) -> SystemTime
Performs the conversion.
sourceimpl PartialEq<PositiveTimestamp> for PositiveTimestamp
impl PartialEq<PositiveTimestamp> for PositiveTimestamp
sourcefn eq(&self, other: &PositiveTimestamp) -> bool
fn eq(&self, other: &PositiveTimestamp) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &PositiveTimestamp) -> bool
fn ne(&self, other: &PositiveTimestamp) -> bool
This method tests for !=
.
sourceimpl ToBase32 for PositiveTimestamp
impl ToBase32 for PositiveTimestamp
sourcefn 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>
Encode as base32 and write it to the supplied writer Implementations shouldn’t allocate. Read more
impl Eq for PositiveTimestamp
impl StructuralEq for PositiveTimestamp
impl StructuralPartialEq for PositiveTimestamp
Auto Trait Implementations
impl RefUnwindSafe for PositiveTimestamp
impl Send for PositiveTimestamp
impl Sync for PositiveTimestamp
impl Unpin for PositiveTimestamp
impl UnwindSafe for PositiveTimestamp
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more