Struct PositiveTimestamp
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§
§impl PositiveTimestamp
impl PositiveTimestamp
pub fn from_unix_timestamp(
unix_seconds: u64,
) -> Result<PositiveTimestamp, CreationError>
pub fn from_unix_timestamp( unix_seconds: u64, ) -> Result<PositiveTimestamp, CreationError>
Creates a PositiveTimestamp
from a Unix timestamp in the range 0..=MAX_TIMESTAMP
.
Otherwise, returns a CreationError::TimestampOutOfBounds
.
pub fn from_duration_since_epoch(
duration: Duration,
) -> Result<PositiveTimestamp, CreationError>
pub fn from_duration_since_epoch( duration: Duration, ) -> Result<PositiveTimestamp, 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
.
pub fn as_unix_timestamp(&self) -> u64
pub fn as_unix_timestamp(&self) -> u64
Returns the Unix timestamp representing the stored time
pub 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
Trait Implementations§
§impl Clone for PositiveTimestamp
impl Clone for PositiveTimestamp
§fn clone(&self) -> PositiveTimestamp
fn clone(&self) -> PositiveTimestamp
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for PositiveTimestamp
impl Debug for PositiveTimestamp
§impl From<PositiveTimestamp> for Duration
impl From<PositiveTimestamp> for Duration
§fn from(val: PositiveTimestamp) -> Duration
fn from(val: PositiveTimestamp) -> Duration
Converts to this type from the input type.
§impl Hash for PositiveTimestamp
impl Hash for PositiveTimestamp
§impl Ord for PositiveTimestamp
impl Ord for PositiveTimestamp
§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,
Compares and returns the maximum of two values. Read more
§impl PartialEq for PositiveTimestamp
impl PartialEq for PositiveTimestamp
§impl PartialOrd for PositiveTimestamp
impl PartialOrd for PositiveTimestamp
impl Eq for PositiveTimestamp
impl StructuralPartialEq for PositiveTimestamp
Auto Trait Implementations§
impl Freeze for PositiveTimestamp
impl Send for PositiveTimestamp
impl Sync for PositiveTimestamp
impl RefUnwindSafe for PositiveTimestamp
impl Unpin for PositiveTimestamp
impl UnwindSafe for PositiveTimestamp
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request