pub struct Duration {
pub seconds: i64,
pub nanosecond: i32,
}Expand description
A signed, exact length of time.
This is a well-known extension type (see ext). The
seconds and nanoseconds always have the same sign: -1.5 seconds are
seconds: -1 and nanosecond: -500_000_000.
The fallback is the ISO 8601 representation as string (PT1H30M,
-PT0.5S). Only hours, minutes and seconds are used and accepted as
days, months and years are not of a fixed length. Fractions are only
supported for seconds.
use deser::ext::Duration;
let duration: Duration = "PT1H0.5S".parse().unwrap();
assert_eq!(duration, Duration { seconds: 3600, nanosecond: 500_000_000 });
assert_eq!(duration.to_string(), "PT1H0.5S");core::time::Duration serializes as Duration, as do the duration
types of jiff, chrono and time with the respective features.
Fields§
§seconds: i64The whole seconds.
nanosecond: i32The fraction of the second in nanoseconds (-999_999_999 to
999_999_999).
Implementations§
Trait Implementations§
impl Copy for Duration
Source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
Source§fn deserialize_atom(
slot: &mut Slot<Self>,
atom: Atom<'_>,
state: &mut State,
) -> Result<(), Error>
fn deserialize_atom( slot: &mut Slot<Self>, atom: Atom<'_>, state: &mut State, ) -> Result<(), Error>
Deserializes an atom into the slot. Read more
Source§fn expecting() -> Cow<'static, str>
fn expecting() -> Cow<'static, str>
Returns what the value expects, for error messages. Read more
Source§fn deserialize_into<'out>(
out: &'out mut Option<T>,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_into<'out>( out: &'out mut Option<T>, state: &mut State, ) -> SinkHandle<'out, 'de>
Creates a sink that deserializes the value into the given slot. Read more
Source§fn deserialize_borrowed_atom(
slot: &mut Slot<T, Self>,
atom: Atom<'de>,
state: &mut State,
) -> Result<(), Error>
fn deserialize_borrowed_atom( slot: &mut Slot<T, Self>, atom: Atom<'de>, state: &mut State, ) -> Result<(), Error>
Deserializes an atom that borrows from the data being deserialized
into the slot. Read more
Source§fn describe_type(d: &mut dyn Describe)
fn describe_type(d: &mut dyn Describe)
Describes the Rust shape of the type. Read more
Source§fn initial_value() -> Option<T>
fn initial_value() -> Option<T>
Provides the value of a missing struct field. Read more
Source§fn deserialize_update<'out>(
value: &'out mut T,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_update<'out>( value: &'out mut T, state: &mut State, ) -> SinkHandle<'out, 'de>
Creates a sink that updates an existing value. 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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
Source§impl Serialize for Duration
impl Serialize for Duration
Source§fn serialize<'a>(value: &'a Self, _state: &mut State) -> Result<Emit<'a>, Error>
fn serialize<'a>(value: &'a Self, _state: &mut State) -> Result<Emit<'a>, Error>
Serializes the value.
Source§fn finish(value: &T, state: &mut State) -> Result<(), Error>
fn finish(value: &T, state: &mut State) -> Result<(), Error>
Invoked after the serialization finished. Read more
Source§fn container_shape(value: &T) -> ContainerShape
fn container_shape(value: &T) -> ContainerShape
Returns the shape of the value if it’s a map or sequence. Read more
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> BorrowedExtension for Twhere
T: Extension,
impl<T> BorrowedExtension for Twhere
T: Extension,
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.