pub struct DurationFormatOptions { /* private fields */ }Expand description
Format a duration as e.g. 3.2s or 1h 42m.
Implementations§
Source§impl DurationFormatOptions
impl DurationFormatOptions
Sourcepub fn with_only_seconds(self, only_seconds: bool) -> Self
pub fn with_only_seconds(self, only_seconds: bool) -> Self
If true, format 63 seconds as 63s. If false, format it as 1m3s
Sourcepub fn with_always_sign(self, always_sign: bool) -> Self
pub fn with_always_sign(self, always_sign: bool) -> Self
Always show the sign, even if it is positive (+).
Sourcepub fn with_min_decimals(self, min_decimals: usize) -> Self
pub fn with_min_decimals(self, min_decimals: usize) -> Self
Number of sub-second decimals to at least show.
So 3 means at least millisecond accuracy, etc.
Supported values: 0,1,3,6,9
Sourcepub fn with_max_decimals(self, max_decimals: usize) -> Self
pub fn with_max_decimals(self, max_decimals: usize) -> Self
Number of sub-second to show at most.
So 6 means at most microsecond accuracy, etc.
Supported values: 0,1,3,6,9
Sourcepub fn round_towards_zero(self) -> Self
pub fn round_towards_zero(self) -> Self
When we hit with_max_decimals, round towards zero.
Sourcepub fn round_to_closest(self) -> Self
pub fn round_to_closest(self) -> Self
When we hit with_max_decimals, round to closest.
Sourcepub fn format_nanos(self, ns: i64) -> String
pub fn format_nanos(self, ns: i64) -> String
Formats nanoseconds in a pretty way, as specific.
This function is NOT optimized for performance (and does many small allocations).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DurationFormatOptions
impl RefUnwindSafe for DurationFormatOptions
impl Send for DurationFormatOptions
impl Sync for DurationFormatOptions
impl Unpin for DurationFormatOptions
impl UnwindSafe for DurationFormatOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more