Struct humantime::Duration [] [src]

pub struct Duration(_);

A wrapper for duration that has FromStr implementation

This is useful if you want to use it somewhere where FromStr is expected.

See parse_duration for the description of the format.

Example

use std::time::Duration;
let x: Duration;
x = "12h 5min 2ns".parse::<humantime::Duration>().unwrap().into();
assert_eq!(x, Duration::new(12*3600 + 5*60, 2))

Methods from Deref<Target=StdDuration>

fn as_secs(&self) -> u64
1.3.0

Returns the number of whole seconds represented by this duration.

The extra precision represented by this duration is ignored (e.g. extra nanoseconds are not represented in the returned value).

fn subsec_nanos(&self) -> u32
1.3.0

Returns the nanosecond precision represented by this duration.

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 (e.g. it is less than one billion).

Trait Implementations

impl Copy for Duration
[src]

impl Clone for Duration
[src]

fn clone(&self) -> Duration

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Hash for Duration
[src]

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

Feeds this value into the state given, updating the hasher as necessary.

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

Feeds a slice of this type into the state provided.

impl Eq for Duration
[src]

impl PartialEq for Duration
[src]

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

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

fn ne(&self, __arg_0: &Duration) -> bool

This method tests for !=.

impl Debug for Duration
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl AsRef<StdDuration> for Duration
[src]

fn as_ref(&self) -> &StdDuration

Performs the conversion.

impl Deref for Duration
[src]

type Target = StdDuration

The resulting type after dereferencing

fn deref(&self) -> &StdDuration

The method called to dereference a value

impl Into<StdDuration> for Duration
[src]

fn into(self) -> StdDuration

Performs the conversion.

impl From<StdDuration> for Duration
[src]

fn from(dur: StdDuration) -> Duration

Performs the conversion.

impl FromStr for Duration
[src]

type Err = Error

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<DurationError>

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