pub struct MyDuration(/* private fields */);Expand description
Implementation of time duration that wraps Duration to better satisfy the requirements of the xAPI specifications.
Specifically, this implementation considers the patterns [PnnW] and
[PnnYnnMnnDTnnHnnMnnS] as valid.
Implementations§
Source§impl MyDuration
impl MyDuration
Sourcepub fn new(
positive: bool,
day: u32,
second: u32,
microsecond: u32,
) -> Result<Self, DataError>
pub fn new( positive: bool, day: u32, second: u32, microsecond: u32, ) -> Result<Self, DataError>
Construct a new instance from given parameters.
Sourcepub fn truncate(&self) -> Self
pub fn truncate(&self) -> Self
Return a clone of this excluding precisions beyond 0.01 second.
Needed b/c 4.2.7 Additional Requirements for Data Types / Duration states:
When making a comparison (e.g. as a part of the statement signing process) of Statements in regard to a Duration, any precision beyond 0.01 second precision shall not be included in the comparison.
Sourcepub fn microsecond(&self) -> u32
pub fn microsecond(&self) -> u32
Return the number of microseconds, range 0 to 999999, in this.
Sourcepub fn to_iso8601(&self) -> String
pub fn to_iso8601(&self) -> String
Return this in ISO8601 format; i.e. “P9DT9H9M9.99S”
Trait Implementations§
Source§impl Clone for MyDuration
impl Clone for MyDuration
Source§fn clone(&self) -> MyDuration
fn clone(&self) -> MyDuration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MyDuration
impl Debug for MyDuration
Source§impl<'de> Deserialize<'de> for MyDuration
impl<'de> Deserialize<'de> for MyDuration
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>,
Source§impl Display for MyDuration
impl Display for MyDuration
Source§impl Fingerprint for MyDuration
impl Fingerprint for MyDuration
Source§impl FromStr for MyDuration
impl FromStr for MyDuration
Source§impl PartialEq for MyDuration
impl PartialEq for MyDuration
Source§fn eq(&self, other: &MyDuration) -> bool
fn eq(&self, other: &MyDuration) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for MyDuration
impl Serialize for MyDuration
impl StructuralPartialEq for MyDuration
Auto Trait Implementations§
impl Freeze for MyDuration
impl RefUnwindSafe for MyDuration
impl Send for MyDuration
impl Sync for MyDuration
impl Unpin for MyDuration
impl UnsafeUnpin for MyDuration
impl UnwindSafe for MyDuration
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.