Trait fancy_duration::AsTimes
source · pub trait AsTimes: Sized {
// Required methods
fn as_times(&self) -> (u64, u64);
fn parse_to_duration(s: &str) -> Result<Self, Error>;
}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§
sourcefn as_times(&self) -> (u64, u64)
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.
sourcefn parse_to_duration(s: &str) -> Result<Self, Error>
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.
Object Safety§
This trait is not object safe.