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_system_time(
time: SystemTime,
) -> Result<PositiveTimestamp, CreationError>
pub fn from_system_time( time: SystemTime, ) -> Result<PositiveTimestamp, CreationError>
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
.
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
pub fn as_time(&self) -> SystemTime
pub fn as_time(&self) -> SystemTime
Returns the SystemTime
representing the stored time
Trait Implementations§
§impl Clone for PositiveTimestamp
impl Clone for PositiveTimestamp
§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 more§impl Debug for PositiveTimestamp
impl Debug for PositiveTimestamp
§impl From<PositiveTimestamp> for SystemTime
impl From<PositiveTimestamp> for SystemTime
§fn from(val: PositiveTimestamp) -> SystemTime
fn from(val: PositiveTimestamp) -> SystemTime
§impl FromBase32 for PositiveTimestamp
impl FromBase32 for PositiveTimestamp
§type Err = Bolt11ParseError
type Err = Bolt11ParseError
§fn from_base32(
b32: &[u5],
) -> Result<PositiveTimestamp, <PositiveTimestamp as FromBase32>::Err>
fn from_base32( b32: &[u5], ) -> Result<PositiveTimestamp, <PositiveTimestamp as FromBase32>::Err>
Self
.§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,
§impl PartialEq for PositiveTimestamp
impl PartialEq for PositiveTimestamp
§impl PartialOrd for PositiveTimestamp
impl PartialOrd for PositiveTimestamp
§impl ToBase32 for PositiveTimestamp
impl ToBase32 for PositiveTimestamp
§fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
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§
§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
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
)§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
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
§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
key
and return true
if they are equal.§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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request