pub struct Duration(/* private fields */);Expand description
A signed span of time with nanosecond precision.
Implementations§
Source§impl Duration
impl Duration
Sourcepub const MAX: Self
pub const MAX: Self
The largest span: i64::MAX milliseconds, the range LeanCTX’s
durations have always had; the smallest is its negation.
Sourcepub const fn try_days(n: i64) -> Option<Self>
pub const fn try_days(n: i64) -> Option<Self>
n days of 24 hours.
None when the span does not fit.
Sourcepub const fn try_minutes(n: i64) -> Option<Self>
pub const fn try_minutes(n: i64) -> Option<Self>
n minutes.
None when the span does not fit.
Sourcepub const fn try_seconds(n: i64) -> Option<Self>
pub const fn try_seconds(n: i64) -> Option<Self>
n seconds.
None when the span does not fit.
Sourcepub const fn milliseconds(n: i64) -> Self
pub const fn milliseconds(n: i64) -> Self
n milliseconds.
Panics when the span does not fit.
Sourcepub const fn try_milliseconds(n: i64) -> Option<Self>
pub const fn try_milliseconds(n: i64) -> Option<Self>
n milliseconds.
None when the span does not fit.
Sourcepub const fn microseconds(n: i64) -> Self
pub const fn microseconds(n: i64) -> Self
n microseconds.
Panics when the span does not fit.
Sourcepub const fn try_microseconds(n: i64) -> Option<Self>
pub const fn try_microseconds(n: i64) -> Option<Self>
n microseconds.
None when the span does not fit.
Sourcepub fn nanoseconds(n: i64) -> Self
pub fn nanoseconds(n: i64) -> Self
n nanoseconds.
Sourcepub fn num_minutes(self) -> i64
pub fn num_minutes(self) -> i64
Whole minutes, truncated towards zero.
Sourcepub fn num_seconds(self) -> i64
pub fn num_seconds(self) -> i64
Whole seconds, truncated towards zero.
Sourcepub fn num_milliseconds(self) -> i64
pub fn num_milliseconds(self) -> i64
Whole milliseconds, truncated towards zero.
Sourcepub fn num_microseconds(self) -> Option<i64>
pub fn num_microseconds(self) -> Option<i64>
Whole microseconds, truncated towards zero; None past i64.
Sourcepub fn num_nanoseconds(self) -> Option<i64>
pub fn num_nanoseconds(self) -> Option<i64>
Nanoseconds; None past i64.
Sourcepub fn subsec_nanos(self) -> i32
pub fn subsec_nanos(self) -> i32
The nanoseconds past Duration::num_seconds, with its sign.
Sourcepub fn as_seconds_f64(self) -> f64
pub fn as_seconds_f64(self) -> f64
Whole seconds as f64, with the fraction.
Sourcepub fn is_negative(self) -> bool
pub fn is_negative(self) -> bool
Below zero?
Sourcepub fn checked_add(&self, rhs: &Self) -> Option<Self>
pub fn checked_add(&self, rhs: &Self) -> Option<Self>
self + rhs, None outside Duration::MIN..=Duration::MAX.
Sourcepub fn checked_sub(&self, rhs: &Self) -> Option<Self>
pub fn checked_sub(&self, rhs: &Self) -> Option<Self>
self - rhs, None outside Duration::MIN..=Duration::MAX.
Sourcepub fn from_std(d: Duration) -> Result<Self, OutOfRangeError>
pub fn from_std(d: Duration) -> Result<Self, OutOfRangeError>
From a std duration; Err past Duration::MAX.
Sourcepub fn to_std(self) -> Result<Duration, OutOfRangeError>
pub fn to_std(self) -> Result<Duration, OutOfRangeError>
To a std duration; Err when negative.
Sourcepub const fn from_jiff(d: SignedDuration) -> Self
pub const fn from_jiff(d: SignedDuration) -> Self
Wraps a jiff signed duration.
Sourcepub const fn as_jiff(self) -> SignedDuration
pub const fn as_jiff(self) -> SignedDuration
The jiff signed duration underneath.
Trait Implementations§
Source§impl Add<Duration> for CivilDateTime
impl Add<Duration> for CivilDateTime
Source§impl Add<Duration> for UtcDateTime
impl Add<Duration> for UtcDateTime
Source§impl Add<Duration> for OffsetDateTime
impl Add<Duration> for OffsetDateTime
Source§impl AddAssign for Duration
impl AddAssign for Duration
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl AddAssign<Duration> for UtcDateTime
impl AddAssign<Duration> for UtcDateTime
Source§fn add_assign(&mut self, d: Duration)
fn add_assign(&mut self, d: Duration)
+= operation. Read moreimpl Copy for Duration
impl Eq for Duration
Source§impl Ord for Duration
impl Ord for Duration
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
impl StructuralPartialEq for Duration
Source§impl Sub<Duration> for CivilDateTime
impl Sub<Duration> for CivilDateTime
Source§impl Sub<Duration> for UtcDateTime
impl Sub<Duration> for UtcDateTime
Source§impl Sub<Duration> for OffsetDateTime
impl Sub<Duration> for OffsetDateTime
Source§impl SubAssign for Duration
impl SubAssign for Duration
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreSource§impl SubAssign<Duration> for UtcDateTime
impl SubAssign<Duration> for UtcDateTime
Source§fn sub_assign(&mut self, d: Duration)
fn sub_assign(&mut self, d: Duration)
-= operation. Read more