pub trait AsTimes: Sized {
    // Required methods
    fn as_times(&self) -> (u64, u64);
    fn parse_to_duration(s: &str) -> Result<Self, Error>;
    fn from_times(&self, s: u64, ns: u64) -> Self;
}
Expand description

AsTimes is the trait that allows FancyDuration to represent durations. Implementing these methods will allow any compatible type to work with FancyDuration.

Required Methods§

source

fn as_times(&self) -> (u64, u64)

To implement a fancier duration, just have your duration return the seconds and nanoseconds (in a tuple) as a part of the following method call, as well as a method to handle parsing. The nanoseconds value should just represent the subsecond count, not the seconds.

source

fn parse_to_duration(s: &str) -> Result<Self, Error>

This function implements parsing to return the inner duration. FancyDuration::parse_to_ns is the standard parser and provides you with data to construct most duration types.

source

fn from_times(&self, s: u64, ns: u64) -> Self

Yield one of this implementing duration from a pair of (seconds, nanoseconds).

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl AsTimes for Duration

source§

fn as_times(&self) -> (u64, u64)

source§

fn parse_to_duration(s: &str) -> Result<Self, Error>

source§

fn from_times(&self, s: u64, ns: u64) -> Self

Implementors§