pub struct HumanDuration(/* private fields */);Expand description
Human-readable duration parsed from strings like 1h, 30m, 45s,
500ms, or combinations such as 1h30m45s.
Supported units: h (hours), m (minutes), s (seconds), ms
(milliseconds). Units must appear in descending order, each at most once.
Implementations§
Source§impl HumanDuration
impl HumanDuration
Sourcepub fn parse(s: &str) -> PrimitiveResult<Self>
pub fn parse(s: &str) -> PrimitiveResult<Self>
Parses a human-readable duration string.
§Examples
let d = HumanDuration::parse("1h30m").unwrap();
assert_eq!(d.as_secs(), 5400);Sourcepub fn as_duration(self) -> Duration
pub fn as_duration(self) -> Duration
Returns the underlying core::time::Duration.
Trait Implementations§
Source§impl Clone for HumanDuration
impl Clone for HumanDuration
Source§fn clone(&self) -> HumanDuration
fn clone(&self) -> HumanDuration
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for HumanDuration
Source§impl Debug for HumanDuration
impl Debug for HumanDuration
Source§impl Display for HumanDuration
impl Display for HumanDuration
impl Eq for HumanDuration
Source§impl FromStr for HumanDuration
impl FromStr for HumanDuration
Source§impl Hash for HumanDuration
impl Hash for HumanDuration
Source§impl Ord for HumanDuration
impl Ord for HumanDuration
Source§fn cmp(&self, other: &HumanDuration) -> Ordering
fn cmp(&self, other: &HumanDuration) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for HumanDuration
impl PartialEq for HumanDuration
Source§fn eq(&self, other: &HumanDuration) -> bool
fn eq(&self, other: &HumanDuration) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialEq<&String> for HumanDuration
Available on crate feature alloc only.
impl PartialEq<&String> for HumanDuration
Available on crate feature
alloc only.Source§impl PartialEq<&str> for HumanDuration
impl PartialEq<&str> for HumanDuration
Source§impl PartialEq<String> for HumanDuration
Available on crate feature alloc only.
impl PartialEq<String> for HumanDuration
Available on crate feature
alloc only.Source§impl PartialEq<str> for HumanDuration
impl PartialEq<str> for HumanDuration
Source§impl PartialOrd for HumanDuration
impl PartialOrd for HumanDuration
impl StructuralPartialEq for HumanDuration
Auto Trait Implementations§
impl Freeze for HumanDuration
impl RefUnwindSafe for HumanDuration
impl Send for HumanDuration
impl Sync for HumanDuration
impl Unpin for HumanDuration
impl UnsafeUnpin for HumanDuration
impl UnwindSafe for HumanDuration
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