pub struct Duration { /* private fields */ }Expand description
An ISO 8601 duration with separate month, day, and nanosecond components.
The three components are kept separate because months have variable length and cannot be converted to days without a reference date. This means durations are only partially ordered.
§Examples
use grafeo_common::types::Duration;
let d = Duration::parse("P1Y2M3DT4H5M6S").unwrap();
assert_eq!(d.months(), 14); // 1 year + 2 months
assert_eq!(d.days(), 3);
assert_eq!(d.to_string(), "P1Y2M3DT4H5M6S");Implementations§
Source§impl Duration
impl Duration
Sourcepub const fn new(months: i64, days: i64, nanos: i64) -> Self
pub const fn new(months: i64, days: i64, nanos: i64) -> Self
Creates a duration from months, days, and nanoseconds.
Sourcepub const fn from_months(months: i64) -> Self
pub const fn from_months(months: i64) -> Self
Creates a duration from a number of months.
Sourcepub const fn from_nanos(nanos: i64) -> Self
pub const fn from_nanos(nanos: i64) -> Self
Creates a duration from nanoseconds.
Sourcepub const fn from_seconds(secs: i64) -> Self
pub const fn from_seconds(secs: i64) -> Self
Creates a duration from seconds.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
impl Copy for Duration
impl Eq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnsafeUnpin for Duration
impl UnwindSafe for Duration
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.