logo
pub struct Timeout(_);
Expand description

Timeout durations

Methods from Deref<Target = Duration>

Returns true if this Duration spans no time.

Examples
use std::time::Duration;

assert!(Duration::ZERO.is_zero());
assert!(Duration::new(0, 0).is_zero());
assert!(Duration::from_nanos(0).is_zero());
assert!(Duration::from_secs(0).is_zero());

assert!(!Duration::new(1, 1).is_zero());
assert!(!Duration::from_nanos(1).is_zero());
assert!(!Duration::from_secs(1).is_zero());

Returns the number of whole seconds contained by this Duration.

The returned value does not include the fractional (nanosecond) part of the duration, which can be obtained using subsec_nanos.

Examples
use std::time::Duration;

let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_secs(), 5);

To determine the total number of seconds represented by the Duration, use as_secs in combination with subsec_nanos:

use std::time::Duration;

let duration = Duration::new(5, 730023852);

assert_eq!(5.730023852,
           duration.as_secs() as f64
           + duration.subsec_nanos() as f64 * 1e-9);

Returns the fractional part of this Duration, in whole milliseconds.

This method does not return the length of the duration when represented by milliseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one thousand).

Examples
use std::time::Duration;

let duration = Duration::from_millis(5432);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_millis(), 432);

Returns the fractional part of this Duration, in whole microseconds.

This method does not return the length of the duration when represented by microseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one million).

Examples
use std::time::Duration;

let duration = Duration::from_micros(1_234_567);
assert_eq!(duration.as_secs(), 1);
assert_eq!(duration.subsec_micros(), 234_567);

Returns the fractional part of this Duration, in nanoseconds.

This method does not return the length of the duration when represented by nanoseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one billion).

Examples
use std::time::Duration;

let duration = Duration::from_millis(5010);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_nanos(), 10_000_000);

Returns the total number of whole milliseconds contained by this Duration.

Examples
use std::time::Duration;

let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_millis(), 5730);

Returns the total number of whole microseconds contained by this Duration.

Examples
use std::time::Duration;

let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_micros(), 5730023);

Returns the total number of nanoseconds contained by this Duration.

Examples
use std::time::Duration;

let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_nanos(), 5730023852);

Returns the number of seconds contained by this Duration as f64.

The returned value does include the fractional (nanosecond) part of the duration.

Examples
use std::time::Duration;

let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.as_secs_f64(), 2.7);

Returns the number of seconds contained by this Duration as f32.

The returned value does include the fractional (nanosecond) part of the duration.

Examples
use std::time::Duration;

let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.as_secs_f32(), 2.7);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Parse Timeout from string ending in s or ms

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.