[−][src]Struct time::Duration
ISO 8601 time duration with nanosecond precision. This also allows for the negative duration; see individual methods for details.
Methods
impl Duration[src]
impl Durationpub fn weeks(weeks: i64) -> Duration[src]
pub fn weeks(weeks: i64) -> DurationMakes a new Duration with given number of weeks.
Equivalent to Duration::seconds(weeks * 7 * 24 * 60 * 60) with overflow checks.
Panics when the duration is out of bounds.
pub fn days(days: i64) -> Duration[src]
pub fn days(days: i64) -> DurationMakes a new Duration with given number of days.
Equivalent to Duration::seconds(days * 24 * 60 * 60) with overflow checks.
Panics when the duration is out of bounds.
pub fn hours(hours: i64) -> Duration[src]
pub fn hours(hours: i64) -> DurationMakes a new Duration with given number of hours.
Equivalent to Duration::seconds(hours * 60 * 60) with overflow checks.
Panics when the duration is out of bounds.
pub fn minutes(minutes: i64) -> Duration[src]
pub fn minutes(minutes: i64) -> DurationMakes a new Duration with given number of minutes.
Equivalent to Duration::seconds(minutes * 60) with overflow checks.
Panics when the duration is out of bounds.
pub fn seconds(seconds: i64) -> Duration[src]
pub fn seconds(seconds: i64) -> DurationMakes a new Duration with given number of seconds.
Panics when the duration is more than i64::MAX milliseconds
or less than i64::MIN milliseconds.
pub fn milliseconds(milliseconds: i64) -> Duration[src]
pub fn milliseconds(milliseconds: i64) -> DurationMakes a new Duration with given number of milliseconds.
pub fn microseconds(microseconds: i64) -> Duration[src]
pub fn microseconds(microseconds: i64) -> DurationMakes a new Duration with given number of microseconds.
pub fn nanoseconds(nanos: i64) -> Duration[src]
pub fn nanoseconds(nanos: i64) -> DurationMakes a new Duration with given number of nanoseconds.
pub fn span<F>(f: F) -> Duration where
F: FnOnce(), [src]
pub fn span<F>(f: F) -> Duration where
F: FnOnce(), Runs a closure, returning the duration of time it took to run the closure.
pub fn num_weeks(&self) -> i64[src]
pub fn num_weeks(&self) -> i64Returns the total number of whole weeks in the duration.
pub fn num_days(&self) -> i64[src]
pub fn num_days(&self) -> i64Returns the total number of whole days in the duration.
pub fn num_hours(&self) -> i64[src]
pub fn num_hours(&self) -> i64Returns the total number of whole hours in the duration.
pub fn num_minutes(&self) -> i64[src]
pub fn num_minutes(&self) -> i64Returns the total number of whole minutes in the duration.
pub fn num_seconds(&self) -> i64[src]
pub fn num_seconds(&self) -> i64Returns the total number of whole seconds in the duration.
pub fn num_milliseconds(&self) -> i64[src]
pub fn num_milliseconds(&self) -> i64Returns the total number of whole milliseconds in the duration,
pub fn num_microseconds(&self) -> Option<i64>[src]
pub fn num_microseconds(&self) -> Option<i64>Returns the total number of whole microseconds in the duration,
or None on overflow (exceeding 263 microseconds in either direction).
pub fn num_nanoseconds(&self) -> Option<i64>[src]
pub fn num_nanoseconds(&self) -> Option<i64>Returns the total number of whole nanoseconds in the duration,
or None on overflow (exceeding 263 nanoseconds in either direction).
pub fn checked_add(&self, rhs: &Duration) -> Option<Duration>[src]
pub fn checked_add(&self, rhs: &Duration) -> Option<Duration>Add two durations, returning None if overflow occurred.
pub fn checked_sub(&self, rhs: &Duration) -> Option<Duration>[src]
pub fn checked_sub(&self, rhs: &Duration) -> Option<Duration>Subtract two durations, returning None if overflow occurred.
pub fn min_value() -> Duration[src]
pub fn min_value() -> DurationThe minimum possible Duration: i64::MIN milliseconds.
pub fn max_value() -> Duration[src]
pub fn max_value() -> DurationThe maximum possible Duration: i64::MAX milliseconds.
pub fn zero() -> Duration[src]
pub fn zero() -> DurationA duration where the stored seconds and nanoseconds are equal to zero.
pub fn is_zero(&self) -> bool[src]
pub fn is_zero(&self) -> boolReturns true if the duration equals Duration::zero().
pub fn from_std(duration: StdDuration) -> Result<Duration, OutOfRangeError>[src]
pub fn from_std(duration: StdDuration) -> Result<Duration, OutOfRangeError>Creates a time::Duration object from std::time::Duration
This function errors when original duration is larger than the maximum value supported for this type.
pub fn to_std(&self) -> Result<StdDuration, OutOfRangeError>[src]
pub fn to_std(&self) -> Result<StdDuration, OutOfRangeError>Creates a std::time::Duration object from time::Duration
This function errors when duration is less than zero. As standard library implementation is limited to non-negative values.
Trait Implementations
impl Clone for Duration[src]
impl Clone for Durationfn clone(&self) -> Duration[src]
fn clone(&self) -> DurationReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Copy for Duration[src]
impl Copy for Durationimpl Eq for Duration[src]
impl Eq for Durationimpl PartialOrd<Duration> for Duration[src]
impl PartialOrd<Duration> for Durationfn partial_cmp(&self, other: &Duration) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &Duration) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Duration) -> bool[src]
fn lt(&self, other: &Duration) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Duration) -> bool[src]
fn le(&self, other: &Duration) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Duration) -> bool[src]
fn gt(&self, other: &Duration) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Duration) -> bool[src]
fn ge(&self, other: &Duration) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl PartialEq<Duration> for Duration[src]
impl PartialEq<Duration> for Durationfn eq(&self, other: &Duration) -> bool[src]
fn eq(&self, other: &Duration) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Duration) -> bool[src]
fn ne(&self, other: &Duration) -> boolThis method tests for !=.
impl Ord for Duration[src]
impl Ord for Durationfn cmp(&self, other: &Duration) -> Ordering[src]
fn cmp(&self, other: &Duration) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl Display for Duration[src]
impl Display for Durationfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Debug for Duration[src]
impl Debug for Durationfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Add<Duration> for Duration[src]
impl Add<Duration> for Durationtype Output = Duration
The resulting type after applying the + operator.
fn add(self, rhs: Duration) -> Duration[src]
fn add(self, rhs: Duration) -> DurationPerforms the + operation.
impl Add<Duration> for Timespec[src]
impl Add<Duration> for Timespectype Output = Timespec
The resulting type after applying the + operator.
fn add(self, other: Duration) -> Timespec[src]
fn add(self, other: Duration) -> TimespecPerforms the + operation.
impl Add<Duration> for SteadyTime[src]
impl Add<Duration> for SteadyTimetype Output = SteadyTime
The resulting type after applying the + operator.
fn add(self, other: Duration) -> SteadyTime[src]
fn add(self, other: Duration) -> SteadyTimePerforms the + operation.
impl Add<Duration> for Tm[src]
impl Add<Duration> for Tmtype Output = Tm
The resulting type after applying the + operator.
fn add(self, other: Duration) -> Tm[src]
fn add(self, other: Duration) -> TmThe resulting Tm is in UTC.
impl Sub<Duration> for Duration[src]
impl Sub<Duration> for Durationtype Output = Duration
The resulting type after applying the - operator.
fn sub(self, rhs: Duration) -> Duration[src]
fn sub(self, rhs: Duration) -> DurationPerforms the - operation.
impl Sub<Duration> for Timespec[src]
impl Sub<Duration> for Timespectype Output = Timespec
The resulting type after applying the - operator.
fn sub(self, other: Duration) -> Timespec[src]
fn sub(self, other: Duration) -> TimespecPerforms the - operation.
impl Sub<Duration> for SteadyTime[src]
impl Sub<Duration> for SteadyTimetype Output = SteadyTime
The resulting type after applying the - operator.
fn sub(self, other: Duration) -> SteadyTime[src]
fn sub(self, other: Duration) -> SteadyTimePerforms the - operation.
impl Sub<Duration> for Tm[src]
impl Sub<Duration> for Tmtype Output = Tm
The resulting type after applying the - operator.
fn sub(self, other: Duration) -> Tm[src]
fn sub(self, other: Duration) -> TmThe resulting Tm is in UTC.
impl Mul<i32> for Duration[src]
impl Mul<i32> for Durationtype Output = Duration
The resulting type after applying the * operator.
fn mul(self, rhs: i32) -> Duration[src]
fn mul(self, rhs: i32) -> DurationPerforms the * operation.
impl Div<i32> for Duration[src]
impl Div<i32> for Durationtype Output = Duration
The resulting type after applying the / operator.
fn div(self, rhs: i32) -> Duration[src]
fn div(self, rhs: i32) -> DurationPerforms the / operation.
impl Neg for Duration[src]
impl Neg for DurationAuto Trait Implementations
Blanket Implementations
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToString for T where
T: Display + ?Sized, [src]
impl<T> ToString for T where
T: Display + ?Sized, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more