tendermint

Struct Timeout

Source
pub struct Timeout(/* private fields */);
Expand description

Timeout durations

Methods from Deref<Target = Duration>§

Source

pub const SECOND: Duration = _

Source

pub const MILLISECOND: Duration = _

Source

pub const MICROSECOND: Duration = _

Source

pub const NANOSECOND: Duration = _

1.53.0 · Source

pub const ZERO: Duration = _

1.53.0 · Source

pub const MAX: Duration = _

1.53.0 · Source

pub fn is_zero(&self) -> bool

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());
1.3.0 · Source

pub fn as_secs(&self) -> u64

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, 730_023_852);
assert_eq!(duration.as_secs(), 5);

To determine the total number of seconds represented by the Duration including the fractional part, use as_secs_f64 or as_secs_f32

1.27.0 · Source

pub fn subsec_millis(&self) -> u32

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(5_432);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_millis(), 432);
1.27.0 · Source

pub fn subsec_micros(&self) -> u32

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);
1.3.0 · Source

pub fn subsec_nanos(&self) -> u32

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(5_010);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_nanos(), 10_000_000);
1.33.0 · Source

pub fn as_millis(&self) -> u128

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

§Examples
use std::time::Duration;

let duration = Duration::new(5, 730_023_852);
assert_eq!(duration.as_millis(), 5_730);
1.33.0 · Source

pub fn as_micros(&self) -> u128

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

§Examples
use std::time::Duration;

let duration = Duration::new(5, 730_023_852);
assert_eq!(duration.as_micros(), 5_730_023);
1.33.0 · Source

pub fn as_nanos(&self) -> u128

Returns the total number of nanoseconds contained by this Duration.

§Examples
use std::time::Duration;

let duration = Duration::new(5, 730_023_852);
assert_eq!(duration.as_nanos(), 5_730_023_852);
1.38.0 · Source

pub fn as_secs_f64(&self) -> f64

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

The returned value includes 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);
1.38.0 · Source

pub fn as_secs_f32(&self) -> f32

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

The returned value includes 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);
Source

pub fn as_millis_f64(&self) -> f64

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

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

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

§Examples
#![feature(duration_millis_float)]
use std::time::Duration;

let dur = Duration::new(2, 345_678_000);
assert_eq!(dur.as_millis_f64(), 2_345.678);
Source

pub fn as_millis_f32(&self) -> f32

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

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

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

§Examples
#![feature(duration_millis_float)]
use std::time::Duration;

let dur = Duration::new(2, 345_678_000);
assert_eq!(dur.as_millis_f32(), 2_345.678);

Trait Implementations§

Source§

impl Clone for Timeout

Source§

fn clone(&self) -> Timeout

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 Timeout

Source§

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

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

impl Deref for Timeout

Source§

type Target = Duration

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Duration

Dereferences the value.
Source§

impl<'de> Deserialize<'de> for Timeout

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Parse Timeout from string ending in s or ms

Source§

impl Display for Timeout

Source§

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

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

impl From<Duration> for Timeout

Source§

fn from(duration: Duration) -> Timeout

Converts to this type from the input type.
Source§

impl From<Timeout> for Duration

Source§

fn from(timeout: Timeout) -> Duration

Converts to this type from the input type.
Source§

impl FromStr for Timeout

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl Ord for Timeout

Source§

fn cmp(&self, other: &Timeout) -> 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,

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

impl PartialEq for Timeout

Source§

fn eq(&self, other: &Timeout) -> 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 for Timeout

Source§

fn partial_cmp(&self, other: &Timeout) -> 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 Serialize for Timeout

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Timeout

Source§

impl Eq for Timeout

Source§

impl StructuralPartialEq for Timeout

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§

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

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,