pub struct Duration { /* private fields */ }Expand description
A structure representing a duration of time in seconds.
§Examples
use typwire::Duration;
let d = Duration::new(3600.0);
assert_eq!(d.seconds(), 3600.0);
assert_eq!(d.hours(), 1.0);Implementations§
Source§impl Duration
impl Duration
Sourcepub const fn builder() -> DurationBuilder
pub const fn builder() -> DurationBuilder
Creates a new builder for constructing a Duration.
§Examples
use typwire::Duration;
let d = Duration::builder().seconds(30.0).minutes(1.0).build();
assert_eq!(d.seconds(), 90.0);Sourcepub const fn seconds(&self) -> f64
pub const fn seconds(&self) -> f64
Returns the total duration in seconds.
§Examples
use typwire::Duration;
let d = Duration::new(120.0);
assert_eq!(d.seconds(), 120.0);Sourcepub const fn minutes(&self) -> f64
pub const fn minutes(&self) -> f64
Returns the total duration in minutes.
§Examples
use typwire::Duration;
let d = Duration::new(120.0);
assert_eq!(d.minutes(), 2.0);Sourcepub const fn hours(&self) -> f64
pub const fn hours(&self) -> f64
Returns the total duration in hours.
§Examples
use typwire::Duration;
let d = Duration::new(3600.0);
assert_eq!(d.hours(), 1.0);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
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 UnwindSafe for Duration
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)