Struct actix_web::cookie::time::Duration

source ·
pub struct Duration { /* private fields */ }
Available on crate feature cookies only.
Expand description

A span of time with nanosecond precision.

Each Duration is composed of a whole number of seconds and a fractional part represented in nanoseconds.

This implementation allows for negative durations, unlike core::time::Duration.

Implementations§

source§

impl Duration

source

pub const ZERO: Duration = _

Equivalent to 0.seconds().

assert_eq!(Duration::ZERO, 0.seconds());
source

pub const NANOSECOND: Duration = _

Equivalent to 1.nanoseconds().

assert_eq!(Duration::NANOSECOND, 1.nanoseconds());
source

pub const MICROSECOND: Duration = _

Equivalent to 1.microseconds().

assert_eq!(Duration::MICROSECOND, 1.microseconds());
source

pub const MILLISECOND: Duration = _

Equivalent to 1.milliseconds().

assert_eq!(Duration::MILLISECOND, 1.milliseconds());
source

pub const SECOND: Duration = _

Equivalent to 1.seconds().

assert_eq!(Duration::SECOND, 1.seconds());
source

pub const MINUTE: Duration = _

Equivalent to 1.minutes().

assert_eq!(Duration::MINUTE, 1.minutes());
source

pub const HOUR: Duration = _

Equivalent to 1.hours().

assert_eq!(Duration::HOUR, 1.hours());
source

pub const DAY: Duration = _

Equivalent to 1.days().

assert_eq!(Duration::DAY, 1.days());
source

pub const WEEK: Duration = _

Equivalent to 1.weeks().

assert_eq!(Duration::WEEK, 1.weeks());
source

pub const MIN: Duration = _

The minimum possible duration. Adding any negative duration to this will cause an overflow.

source

pub const MAX: Duration = _

The maximum possible duration. Adding any positive duration to this will cause an overflow.

source

pub const fn is_zero(self) -> bool

Check if a duration is exactly zero.

assert!(0.seconds().is_zero());
assert!(!1.nanoseconds().is_zero());
source

pub const fn is_negative(self) -> bool

Check if a duration is negative.

assert!((-1).seconds().is_negative());
assert!(!0.seconds().is_negative());
assert!(!1.seconds().is_negative());
source

pub const fn is_positive(self) -> bool

Check if a duration is positive.

assert!(1.seconds().is_positive());
assert!(!0.seconds().is_positive());
assert!(!(-1).seconds().is_positive());
source

pub const fn abs(self) -> Duration

Get the absolute value of the duration.

This method saturates the returned value if it would otherwise overflow.

assert_eq!(1.seconds().abs(), 1.seconds());
assert_eq!(0.seconds().abs(), 0.seconds());
assert_eq!((-1).seconds().abs(), 1.seconds());
source

pub const fn unsigned_abs(self) -> Duration

Convert the existing Duration to a std::time::Duration and its sign. This returns a std::time::Duration and does not saturate the returned value (unlike Duration::abs).

assert_eq!(1.seconds().unsigned_abs(), 1.std_seconds());
assert_eq!(0.seconds().unsigned_abs(), 0.std_seconds());
assert_eq!((-1).seconds().unsigned_abs(), 1.std_seconds());
source

pub const fn new(seconds: i64, nanoseconds: i32) -> Duration

Create a new Duration with the provided seconds and nanoseconds. If nanoseconds is at least ±109, it will wrap to the number of seconds.

assert_eq!(Duration::new(1, 0), 1.seconds());
assert_eq!(Duration::new(-1, 0), (-1).seconds());
assert_eq!(Duration::new(1, 2_000_000_000), 3.seconds());
§Panics

This may panic if an overflow occurs.

source

pub const fn weeks(weeks: i64) -> Duration

Create a new Duration with the given number of weeks. Equivalent to Duration::seconds(weeks * 604_800).

assert_eq!(Duration::weeks(1), 604_800.seconds());
§Panics

This may panic if an overflow occurs.

source

pub const fn days(days: i64) -> Duration

Create a new Duration with the given number of days. Equivalent to Duration::seconds(days * 86_400).

assert_eq!(Duration::days(1), 86_400.seconds());
§Panics

This may panic if an overflow occurs.

source

pub const fn hours(hours: i64) -> Duration

Create a new Duration with the given number of hours. Equivalent to Duration::seconds(hours * 3_600).

assert_eq!(Duration::hours(1), 3_600.seconds());
§Panics

This may panic if an overflow occurs.

source

pub const fn minutes(minutes: i64) -> Duration

Create a new Duration with the given number of minutes. Equivalent to Duration::seconds(minutes * 60).

assert_eq!(Duration::minutes(1), 60.seconds());
§Panics

This may panic if an overflow occurs.

source

pub const fn seconds(seconds: i64) -> Duration

Create a new Duration with the given number of seconds.

assert_eq!(Duration::seconds(1), 1_000.milliseconds());
source

pub fn seconds_f64(seconds: f64) -> Duration

Creates a new Duration from the specified number of seconds represented as f64.

assert_eq!(Duration::seconds_f64(0.5), 0.5.seconds());
assert_eq!(Duration::seconds_f64(-0.5), -0.5.seconds());
source

pub fn seconds_f32(seconds: f32) -> Duration

Creates a new Duration from the specified number of seconds represented as f32.

assert_eq!(Duration::seconds_f32(0.5), 0.5.seconds());
assert_eq!(Duration::seconds_f32(-0.5), (-0.5).seconds());
source

pub fn saturating_seconds_f64(seconds: f64) -> Duration

Creates a new Duration from the specified number of seconds represented as f64. Any values that are out of bounds are saturated at the minimum or maximum respectively. NaN gets turned into a Duration of 0 seconds.

assert_eq!(Duration::saturating_seconds_f64(0.5), 0.5.seconds());
assert_eq!(Duration::saturating_seconds_f64(-0.5), -0.5.seconds());
assert_eq!(
    Duration::saturating_seconds_f64(f64::NAN),
    Duration::new(0, 0),
);
assert_eq!(
    Duration::saturating_seconds_f64(f64::NEG_INFINITY),
    Duration::MIN,
);
assert_eq!(
    Duration::saturating_seconds_f64(f64::INFINITY),
    Duration::MAX,
);
source

pub fn saturating_seconds_f32(seconds: f32) -> Duration

Creates a new Duration from the specified number of seconds represented as f32. Any values that are out of bounds are saturated at the minimum or maximum respectively. NaN gets turned into a Duration of 0 seconds.

assert_eq!(Duration::saturating_seconds_f32(0.5), 0.5.seconds());
assert_eq!(Duration::saturating_seconds_f32(-0.5), (-0.5).seconds());
assert_eq!(
    Duration::saturating_seconds_f32(f32::NAN),
    Duration::new(0, 0),
);
assert_eq!(
    Duration::saturating_seconds_f32(f32::NEG_INFINITY),
    Duration::MIN,
);
assert_eq!(
    Duration::saturating_seconds_f32(f32::INFINITY),
    Duration::MAX,
);
source

pub fn checked_seconds_f64(seconds: f64) -> Option<Duration>

Creates a new Duration from the specified number of seconds represented as f64. Returns None if the Duration can’t be represented.

assert_eq!(Duration::checked_seconds_f64(0.5), Some(0.5.seconds()));
assert_eq!(Duration::checked_seconds_f64(-0.5), Some(-0.5.seconds()));
assert_eq!(Duration::checked_seconds_f64(f64::NAN), None);
assert_eq!(Duration::checked_seconds_f64(f64::NEG_INFINITY), None);
assert_eq!(Duration::checked_seconds_f64(f64::INFINITY), None);
source

pub fn checked_seconds_f32(seconds: f32) -> Option<Duration>

Creates a new Duration from the specified number of seconds represented as f32. Returns None if the Duration can’t be represented.

assert_eq!(Duration::checked_seconds_f32(0.5), Some(0.5.seconds()));
assert_eq!(Duration::checked_seconds_f32(-0.5), Some(-0.5.seconds()));
assert_eq!(Duration::checked_seconds_f32(f32::NAN), None);
assert_eq!(Duration::checked_seconds_f32(f32::NEG_INFINITY), None);
assert_eq!(Duration::checked_seconds_f32(f32::INFINITY), None);
source

pub const fn milliseconds(milliseconds: i64) -> Duration

Create a new Duration with the given number of milliseconds.

assert_eq!(Duration::milliseconds(1), 1_000.microseconds());
assert_eq!(Duration::milliseconds(-1), (-1_000).microseconds());
source

pub const fn microseconds(microseconds: i64) -> Duration

Create a new Duration with the given number of microseconds.

assert_eq!(Duration::microseconds(1), 1_000.nanoseconds());
assert_eq!(Duration::microseconds(-1), (-1_000).nanoseconds());
source

pub const fn nanoseconds(nanoseconds: i64) -> Duration

Create a new Duration with the given number of nanoseconds.

assert_eq!(Duration::nanoseconds(1), 1.microseconds() / 1_000);
assert_eq!(Duration::nanoseconds(-1), (-1).microseconds() / 1_000);
source

pub const fn whole_weeks(self) -> i64

Get the number of whole weeks in the duration.

assert_eq!(1.weeks().whole_weeks(), 1);
assert_eq!((-1).weeks().whole_weeks(), -1);
assert_eq!(6.days().whole_weeks(), 0);
assert_eq!((-6).days().whole_weeks(), 0);
source

pub const fn whole_days(self) -> i64

Get the number of whole days in the duration.

assert_eq!(1.days().whole_days(), 1);
assert_eq!((-1).days().whole_days(), -1);
assert_eq!(23.hours().whole_days(), 0);
assert_eq!((-23).hours().whole_days(), 0);
source

pub const fn whole_hours(self) -> i64

Get the number of whole hours in the duration.

assert_eq!(1.hours().whole_hours(), 1);
assert_eq!((-1).hours().whole_hours(), -1);
assert_eq!(59.minutes().whole_hours(), 0);
assert_eq!((-59).minutes().whole_hours(), 0);
source

pub const fn whole_minutes(self) -> i64

Get the number of whole minutes in the duration.

assert_eq!(1.minutes().whole_minutes(), 1);
assert_eq!((-1).minutes().whole_minutes(), -1);
assert_eq!(59.seconds().whole_minutes(), 0);
assert_eq!((-59).seconds().whole_minutes(), 0);
source

pub const fn whole_seconds(self) -> i64

Get the number of whole seconds in the duration.

assert_eq!(1.seconds().whole_seconds(), 1);
assert_eq!((-1).seconds().whole_seconds(), -1);
assert_eq!(1.minutes().whole_seconds(), 60);
assert_eq!((-1).minutes().whole_seconds(), -60);
source

pub fn as_seconds_f64(self) -> f64

Get the number of fractional seconds in the duration.

assert_eq!(1.5.seconds().as_seconds_f64(), 1.5);
assert_eq!((-1.5).seconds().as_seconds_f64(), -1.5);
source

pub fn as_seconds_f32(self) -> f32

Get the number of fractional seconds in the duration.

assert_eq!(1.5.seconds().as_seconds_f32(), 1.5);
assert_eq!((-1.5).seconds().as_seconds_f32(), -1.5);
source

pub const fn whole_milliseconds(self) -> i128

Get the number of whole milliseconds in the duration.

assert_eq!(1.seconds().whole_milliseconds(), 1_000);
assert_eq!((-1).seconds().whole_milliseconds(), -1_000);
assert_eq!(1.milliseconds().whole_milliseconds(), 1);
assert_eq!((-1).milliseconds().whole_milliseconds(), -1);
source

pub const fn subsec_milliseconds(self) -> i16

Get the number of milliseconds past the number of whole seconds.

Always in the range -999..=999.

assert_eq!(1.4.seconds().subsec_milliseconds(), 400);
assert_eq!((-1.4).seconds().subsec_milliseconds(), -400);
source

pub const fn whole_microseconds(self) -> i128

Get the number of whole microseconds in the duration.

assert_eq!(1.milliseconds().whole_microseconds(), 1_000);
assert_eq!((-1).milliseconds().whole_microseconds(), -1_000);
assert_eq!(1.microseconds().whole_microseconds(), 1);
assert_eq!((-1).microseconds().whole_microseconds(), -1);
source

pub const fn subsec_microseconds(self) -> i32

Get the number of microseconds past the number of whole seconds.

Always in the range -999_999..=999_999.

assert_eq!(1.0004.seconds().subsec_microseconds(), 400);
assert_eq!((-1.0004).seconds().subsec_microseconds(), -400);
source

pub const fn whole_nanoseconds(self) -> i128

Get the number of nanoseconds in the duration.

assert_eq!(1.microseconds().whole_nanoseconds(), 1_000);
assert_eq!((-1).microseconds().whole_nanoseconds(), -1_000);
assert_eq!(1.nanoseconds().whole_nanoseconds(), 1);
assert_eq!((-1).nanoseconds().whole_nanoseconds(), -1);
source

pub const fn subsec_nanoseconds(self) -> i32

Get the number of nanoseconds past the number of whole seconds.

The returned value will always be in the range -999_999_999..=999_999_999.

assert_eq!(1.000_000_400.seconds().subsec_nanoseconds(), 400);
assert_eq!((-1.000_000_400).seconds().subsec_nanoseconds(), -400);
source

pub const fn checked_add(self, rhs: Duration) -> Option<Duration>

Computes self + rhs, returning None if an overflow occurred.

assert_eq!(5.seconds().checked_add(5.seconds()), Some(10.seconds()));
assert_eq!(Duration::MAX.checked_add(1.nanoseconds()), None);
assert_eq!((-5).seconds().checked_add(5.seconds()), Some(0.seconds()));
source

pub const fn checked_sub(self, rhs: Duration) -> Option<Duration>

Computes self - rhs, returning None if an overflow occurred.

assert_eq!(5.seconds().checked_sub(5.seconds()), Some(Duration::ZERO));
assert_eq!(Duration::MIN.checked_sub(1.nanoseconds()), None);
assert_eq!(5.seconds().checked_sub(10.seconds()), Some((-5).seconds()));
source

pub const fn checked_mul(self, rhs: i32) -> Option<Duration>

Computes self * rhs, returning None if an overflow occurred.

assert_eq!(5.seconds().checked_mul(2), Some(10.seconds()));
assert_eq!(5.seconds().checked_mul(-2), Some((-10).seconds()));
assert_eq!(5.seconds().checked_mul(0), Some(0.seconds()));
assert_eq!(Duration::MAX.checked_mul(2), None);
assert_eq!(Duration::MIN.checked_mul(2), None);
source

pub const fn checked_div(self, rhs: i32) -> Option<Duration>

Computes self / rhs, returning None if rhs == 0 or if the result would overflow.

assert_eq!(10.seconds().checked_div(2), Some(5.seconds()));
assert_eq!(10.seconds().checked_div(-2), Some((-5).seconds()));
assert_eq!(1.seconds().checked_div(0), None);
source

pub const fn checked_neg(self) -> Option<Duration>

Computes -self, returning None if the result would overflow.

assert_eq!(5.seconds().checked_neg(), Some((-5).seconds()));
assert_eq!(Duration::MIN.checked_neg(), None);
source

pub const fn saturating_add(self, rhs: Duration) -> Duration

Computes self + rhs, saturating if an overflow occurred.

assert_eq!(5.seconds().saturating_add(5.seconds()), 10.seconds());
assert_eq!(Duration::MAX.saturating_add(1.nanoseconds()), Duration::MAX);
assert_eq!(
    Duration::MIN.saturating_add((-1).nanoseconds()),
    Duration::MIN
);
assert_eq!((-5).seconds().saturating_add(5.seconds()), Duration::ZERO);
source

pub const fn saturating_sub(self, rhs: Duration) -> Duration

Computes self - rhs, saturating if an overflow occurred.

assert_eq!(5.seconds().saturating_sub(5.seconds()), Duration::ZERO);
assert_eq!(Duration::MIN.saturating_sub(1.nanoseconds()), Duration::MIN);
assert_eq!(
    Duration::MAX.saturating_sub((-1).nanoseconds()),
    Duration::MAX
);
assert_eq!(5.seconds().saturating_sub(10.seconds()), (-5).seconds());
source

pub const fn saturating_mul(self, rhs: i32) -> Duration

Computes self * rhs, saturating if an overflow occurred.

assert_eq!(5.seconds().saturating_mul(2), 10.seconds());
assert_eq!(5.seconds().saturating_mul(-2), (-10).seconds());
assert_eq!(5.seconds().saturating_mul(0), Duration::ZERO);
assert_eq!(Duration::MAX.saturating_mul(2), Duration::MAX);
assert_eq!(Duration::MIN.saturating_mul(2), Duration::MIN);
assert_eq!(Duration::MAX.saturating_mul(-2), Duration::MIN);
assert_eq!(Duration::MIN.saturating_mul(-2), Duration::MAX);
source

pub fn time_fn<T>(f: impl FnOnce() -> T) -> (Duration, T)

👎Deprecated since 0.3.32: extremely limited use case, not intended for benchmarking
Available on crate feature std only.

Runs a closure, returning the duration of time it took to run. The return value of the closure is provided in the second part of the tuple.

Trait Implementations§

source§

impl Add<Duration> for Date

source§

fn add(self, duration: Duration) -> <Date as Add<Duration>>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = Date

The resulting type after applying the + operator.
source§

impl Add<Duration> for Duration

source§

fn add(self, std_duration: Duration) -> <Duration as Add<Duration>>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = Duration

The resulting type after applying the + operator.
source§

impl Add<Duration> for Instant

source§

fn add(self, duration: Duration) -> <Instant as Add<Duration>>::Output

§Panics

This function may panic if the resulting point in time cannot be represented by the underlying data structure.

§

type Output = Instant

The resulting type after applying the + operator.
source§

impl Add<Duration> for OffsetDateTime

source§

fn add(self, duration: Duration) -> <OffsetDateTime as Add<Duration>>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = OffsetDateTime

The resulting type after applying the + operator.
source§

impl Add<Duration> for PrimitiveDateTime

source§

fn add(self, duration: Duration) -> <PrimitiveDateTime as Add<Duration>>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = PrimitiveDateTime

The resulting type after applying the + operator.
source§

impl Add<Duration> for Time

source§

fn add(self, duration: Duration) -> <Time as Add<Duration>>::Output

Add the sub-day time of the Duration to the Time. Wraps on overflow.

assert_eq!(time!(12:00) + 2.hours(), time!(14:00));
assert_eq!(time!(0:00:01) + (-2).seconds(), time!(23:59:59));
§

type Output = Time

The resulting type after applying the + operator.
source§

impl Add for Duration

source§

fn add(self, rhs: Duration) -> <Duration as Add>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = Duration

The resulting type after applying the + operator.
source§

impl AddAssign<Duration> for Date

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl AddAssign<Duration> for Duration

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl AddAssign<Duration> for Instant

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl AddAssign<Duration> for OffsetDateTime

source§

fn add_assign(&mut self, rhs: Duration)

§Panics

This may panic if an overflow occurs.

source§

impl AddAssign<Duration> for PrimitiveDateTime

source§

fn add_assign(&mut self, duration: Duration)

§Panics

This may panic if an overflow occurs.

source§

impl AddAssign<Duration> for Time

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl AddAssign for Duration

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl Clone for Duration

source§

fn clone(&self) -> Duration

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Duration

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for Duration

source§

fn default() -> Duration

Returns the “default value” for a type. Read more
source§

impl Display for Duration

The format returned by this implementation is not stable and must not be relied upon.

By default this produces an exact, full-precision printout of the duration. For a concise, rounded printout instead, you can use the .N format specifier:

let duration = Duration::new(123456, 789011223);
println!("{duration:.3}");

For the purposes of this implementation, a day is exactly 24 hours and a minute is exactly 60 seconds.

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Div<Duration> for Duration

§

type Output = f64

The resulting type after applying the / operator.
source§

fn div(self, rhs: Duration) -> <Duration as Div<Duration>>::Output

Performs the / operation. Read more
source§

impl Div<f32> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
source§

fn div(self, rhs: f32) -> <Duration as Div<f32>>::Output

Performs the / operation. Read more
source§

impl Div<f64> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
source§

fn div(self, rhs: f64) -> <Duration as Div<f64>>::Output

Performs the / operation. Read more
source§

impl Div<i16> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
source§

fn div(self, rhs: i16) -> <Duration as Div<i16>>::Output

Performs the / operation. Read more
source§

impl Div<i32> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
source§

fn div(self, rhs: i32) -> <Duration as Div<i32>>::Output

Performs the / operation. Read more
source§

impl Div<i8> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
source§

fn div(self, rhs: i8) -> <Duration as Div<i8>>::Output

Performs the / operation. Read more
source§

impl Div<u16> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
source§

fn div(self, rhs: u16) -> <Duration as Div<u16>>::Output

Performs the / operation. Read more
source§

impl Div<u32> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
source§

fn div(self, rhs: u32) -> <Duration as Div<u32>>::Output

Performs the / operation. Read more
source§

impl Div<u8> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
source§

fn div(self, rhs: u8) -> <Duration as Div<u8>>::Output

Performs the / operation. Read more
source§

impl Div for Duration

§

type Output = f64

The resulting type after applying the / operator.
source§

fn div(self, rhs: Duration) -> <Duration as Div>::Output

Performs the / operation. Read more
source§

impl DivAssign<f32> for Duration

source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
source§

impl DivAssign<f64> for Duration

source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
source§

impl DivAssign<i16> for Duration

source§

fn div_assign(&mut self, rhs: i16)

Performs the /= operation. Read more
source§

impl DivAssign<i32> for Duration

source§

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
source§

impl DivAssign<i8> for Duration

source§

fn div_assign(&mut self, rhs: i8)

Performs the /= operation. Read more
source§

impl DivAssign<u16> for Duration

source§

fn div_assign(&mut self, rhs: u16)

Performs the /= operation. Read more
source§

impl DivAssign<u32> for Duration

source§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. Read more
source§

impl DivAssign<u8> for Duration

source§

fn div_assign(&mut self, rhs: u8)

Performs the /= operation. Read more
source§

impl Hash for Duration

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Mul<f32> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> <Duration as Mul<f32>>::Output

Performs the * operation. Read more
source§

impl Mul<f64> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f64) -> <Duration as Mul<f64>>::Output

Performs the * operation. Read more
source§

impl Mul<i16> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i16) -> <Duration as Mul<i16>>::Output

Performs the * operation. Read more
source§

impl Mul<i32> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> <Duration as Mul<i32>>::Output

Performs the * operation. Read more
source§

impl Mul<i8> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i8) -> <Duration as Mul<i8>>::Output

Performs the * operation. Read more
source§

impl Mul<u16> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u16) -> <Duration as Mul<u16>>::Output

Performs the * operation. Read more
source§

impl Mul<u32> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u32) -> <Duration as Mul<u32>>::Output

Performs the * operation. Read more
source§

impl Mul<u8> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u8) -> <Duration as Mul<u8>>::Output

Performs the * operation. Read more
source§

impl MulAssign<f32> for Duration

source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
source§

impl MulAssign<f64> for Duration

source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
source§

impl MulAssign<i16> for Duration

source§

fn mul_assign(&mut self, rhs: i16)

Performs the *= operation. Read more
source§

impl MulAssign<i32> for Duration

source§

fn mul_assign(&mut self, rhs: i32)

Performs the *= operation. Read more
source§

impl MulAssign<i8> for Duration

source§

fn mul_assign(&mut self, rhs: i8)

Performs the *= operation. Read more
source§

impl MulAssign<u16> for Duration

source§

fn mul_assign(&mut self, rhs: u16)

Performs the *= operation. Read more
source§

impl MulAssign<u32> for Duration

source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
source§

impl MulAssign<u8> for Duration

source§

fn mul_assign(&mut self, rhs: u8)

Performs the *= operation. Read more
source§

impl Neg for Duration

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn neg(self) -> <Duration as Neg>::Output

Performs the unary - operation. Read more
source§

impl Ord for Duration

source§

fn cmp(&self, other: &Duration) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Duration> for Duration

source§

fn eq(&self, rhs: &Duration) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for Duration

source§

fn eq(&self, other: &Duration) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Duration> for Duration

source§

fn partial_cmp(&self, rhs: &Duration) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd for Duration

source§

fn partial_cmp(&self, other: &Duration) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<Duration> for Date

source§

fn sub(self, duration: Duration) -> <Date as Sub<Duration>>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = Date

The resulting type after applying the - operator.
source§

impl Sub<Duration> for Duration

source§

fn sub(self, rhs: Duration) -> <Duration as Sub<Duration>>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = Duration

The resulting type after applying the - operator.
source§

impl Sub<Duration> for Instant

source§

fn sub(self, duration: Duration) -> <Instant as Sub<Duration>>::Output

§Panics

This function may panic if the resulting point in time cannot be represented by the underlying data structure.

§

type Output = Instant

The resulting type after applying the - operator.
source§

impl Sub<Duration> for OffsetDateTime

source§

fn sub(self, rhs: Duration) -> <OffsetDateTime as Sub<Duration>>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = OffsetDateTime

The resulting type after applying the - operator.
source§

impl Sub<Duration> for PrimitiveDateTime

source§

fn sub(self, duration: Duration) -> <PrimitiveDateTime as Sub<Duration>>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = PrimitiveDateTime

The resulting type after applying the - operator.
source§

impl Sub<Duration> for Time

source§

fn sub(self, duration: Duration) -> <Time as Sub<Duration>>::Output

Subtract the sub-day time of the Duration from the Time. Wraps on overflow.

assert_eq!(time!(14:00) - 2.hours(), time!(12:00));
assert_eq!(time!(23:59:59) - (-2).seconds(), time!(0:00:01));
§

type Output = Time

The resulting type after applying the - operator.
source§

impl Sub for Duration

source§

fn sub(self, rhs: Duration) -> <Duration as Sub>::Output

§Panics

This may panic if an overflow occurs.

§

type Output = Duration

The resulting type after applying the - operator.
source§

impl SubAssign<Duration> for Date

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl SubAssign<Duration> for Duration

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl SubAssign<Duration> for Instant

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl SubAssign<Duration> for OffsetDateTime

source§

fn sub_assign(&mut self, rhs: Duration)

§Panics

This may panic if an overflow occurs.

source§

impl SubAssign<Duration> for PrimitiveDateTime

source§

fn sub_assign(&mut self, duration: Duration)

§Panics

This may panic if an overflow occurs.

source§

impl SubAssign<Duration> for Time

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl SubAssign for Duration

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl<'a> Sum<&'a Duration> for Duration

source§

fn sum<I>(iter: I) -> Duration
where I: Iterator<Item = &'a Duration>,

Takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Sum for Duration

source§

fn sum<I>(iter: I) -> Duration
where I: Iterator<Item = Duration>,

Takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl TryFrom<Duration> for Duration

§

type Error = ConversionRange

The type returned in the event of a conversion error.
source§

fn try_from(original: Duration) -> Result<Duration, ConversionRange>

Performs the conversion.
source§

impl Copy for Duration

source§

impl Eq for Duration

source§

impl StructuralPartialEq for Duration

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more