pub struct Duration {
pub months: i64,
pub days: i64,
pub seconds: i64,
pub nanos: i32,
}Expand description
Calendar/clock duration with month, day, second, and nanosecond components —
the model GQL/ISO 8601 uses (months and days are not fixed-length, so they are
kept distinct from seconds rather than collapsed). Construct from an ISO 8601
duration string such as P1Y2M10DT2H30M via Duration::parse.
Ordering is structural (months, then days, then seconds, then nanos): a deterministic total order for sorting, not a calendar-normalized comparison.
Fields§
§months: i64§days: i64§seconds: i64§nanos: i32Implementations§
Source§impl Duration
impl Duration
Sourcepub fn parse(value: impl AsRef<str>) -> Result<Self>
pub fn parse(value: impl AsRef<str>) -> Result<Self>
Parses an ISO 8601 duration: P[nY][nM][nW][nD][T[nH][nM][nS]]. Years map
to 12 months and weeks to 7 days; the seconds field may be fractional
(down to nanosecond precision). At least one component is required.
Sourcepub fn to_iso_string(&self) -> String
pub fn to_iso_string(&self) -> String
Canonical ISO 8601 string (PT0S for the zero duration).
pub fn checked_add(&self, other: &Self) -> Option<Self>
pub fn negated(&self) -> Self
Trait Implementations§
impl Copy for Duration
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
impl Eq for Duration
Source§impl Ord for Duration
impl Ord for Duration
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 PartialOrd for Duration
impl PartialOrd 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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.