[−][src]Struct float_duration::duration::FloatDuration
A time duration stored as a floating point quantity.
Unlike std::time::Duration
or chrono::Duration
, FloatDuration
aims to be convenient and fast to use in simulation and mathematical expressions
rather than to behave like a calendar or perfectly
accurately represent precise time scales.
Internally, a FloatDuration
stores a single f64
number of floating-point seconds,
thus it is only as precise as the f64
type.
Methods
impl FloatDuration
[src]
impl FloatDuration
pub fn years(years: f64) -> FloatDuration
[src]
pub fn years(years: f64) -> FloatDuration
Create a new FloatDuration
representing a number of years.
float_duration
considers one year to be exactly 365 days, with
no consideration of leap years.
pub fn days(days: f64) -> FloatDuration
[src]
pub fn days(days: f64) -> FloatDuration
Create a new FloatDuration
representing a number of days.
pub fn hours(hours: f64) -> FloatDuration
[src]
pub fn hours(hours: f64) -> FloatDuration
Create a new FloatDuration
representing a number of hours.
pub fn minutes(mins: f64) -> FloatDuration
[src]
pub fn minutes(mins: f64) -> FloatDuration
Create a new FloatDuration
representing a number of minutes.
pub fn seconds(secs: f64) -> FloatDuration
[src]
pub fn seconds(secs: f64) -> FloatDuration
Create a new FloatDuration
representing a number of seconds.
pub fn milliseconds(millis: f64) -> FloatDuration
[src]
pub fn milliseconds(millis: f64) -> FloatDuration
Create a new FloatDuration
representing a number of milliseconds.
pub fn microseconds(micros: f64) -> FloatDuration
[src]
pub fn microseconds(micros: f64) -> FloatDuration
Create a new FloatDuration
representing a number of microseconds.
pub fn nanoseconds(nanos: f64) -> FloatDuration
[src]
pub fn nanoseconds(nanos: f64) -> FloatDuration
Create a new FloatDuration
representing a number of nanoseconds.
pub fn as_years(&self) -> f64
[src]
pub fn as_years(&self) -> f64
Return the total number of fractional years represented by the FloatDuration
.
float_duration
considers one year to be exactly 365 days, with
no consideration of leap years.
pub fn as_days(&self) -> f64
[src]
pub fn as_days(&self) -> f64
Return the total number of fractional days represented by the FloatDuration
.
pub fn as_hours(&self) -> f64
[src]
pub fn as_hours(&self) -> f64
Return the total number of fractional hours represented by the FloatDuration
.
pub fn as_minutes(&self) -> f64
[src]
pub fn as_minutes(&self) -> f64
Return the total number of fractional minutes represented by the FloatDuration
.
pub fn as_seconds(&self) -> f64
[src]
pub fn as_seconds(&self) -> f64
Return the total number of fractional seconds represented by the FloatDuration
.
pub fn as_milliseconds(&self) -> f64
[src]
pub fn as_milliseconds(&self) -> f64
Return the total number of fractional milliseconds represented by the FloatDuration
.
pub fn as_microseconds(&self) -> f64
[src]
pub fn as_microseconds(&self) -> f64
Return the total number of fractional microseconds represented by the FloatDuration
.
pub fn as_nanoseconds(&self) -> f64
[src]
pub fn as_nanoseconds(&self) -> f64
Return the total number of fractional nanoseconds represented by the FloatDuration
.
pub fn abs(self) -> FloatDuration
[src]
pub fn abs(self) -> FloatDuration
Compute the absolute value of this duration.
pub fn zero() -> FloatDuration
[src]
pub fn zero() -> FloatDuration
Return a new FloatDuration
that represents zero elapsed time.
pub fn is_zero(&self) -> bool
[src]
pub fn is_zero(&self) -> bool
Returns true is this duration represents zero elapsed time (equals FloatDuration::zero()
).
pub fn is_positive(&self) -> bool
[src]
pub fn is_positive(&self) -> bool
Returns true if the FloatDuration holds a positive amount of time.
pub fn is_negative(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
Returns true if the FloatDuration holds a negative amount of time.
pub fn signum(&self) -> f64
[src]
pub fn signum(&self) -> f64
Return a number that represents the sign of self
.
- 1.0 if the value is positive,
+0.0
orINFINITY
- -1.0 if the value is negative,
-0.0
orNEG_INFINITY
NAN
if the value isNAN
pub fn max(self, other: FloatDuration) -> FloatDuration
[src]
pub fn max(self, other: FloatDuration) -> FloatDuration
Return the maximum of two durations.
pub fn min(self, other: FloatDuration) -> FloatDuration
[src]
pub fn min(self, other: FloatDuration) -> FloatDuration
Return the minimum of two durations.
pub fn min_value() -> FloatDuration
[src]
pub fn min_value() -> FloatDuration
Return a new FloatDuration
with the minimum possible value.
pub fn max_value() -> FloatDuration
[src]
pub fn max_value() -> FloatDuration
Return a new FloatDuration
with the maximum possible value.
pub fn to_std(&self) -> Result<Duration, OutOfRangeError>
[src]
pub fn to_std(&self) -> Result<Duration, OutOfRangeError>
Create a std::time::Duration
object from a FloatDuration
.
Errors
std::time::Duration
does not support negative values or seconds
greater than std::u64::MAX
. This function will return a
DurationError::StdOutOfRange
if the FloatDuration
value is outside
of either of those bounds.
pub fn from_std(duration: Duration) -> FloatDuration
[src]
pub fn from_std(duration: Duration) -> FloatDuration
Create a FloatDuration
object from a std::time::Duration
.
Equivalent to using FloatDuration::from(duration)
impl FloatDuration
[src]
impl FloatDuration
pub fn to_chrono(&self) -> Result<Duration, OutOfRangeError>
[src]
pub fn to_chrono(&self) -> Result<Duration, OutOfRangeError>
Create a chrono::Duration
object from a FloatDuration
.
Errors
Presently, the conversion to chrono::Duration
first goes through
std::time::Duration
and return an error if to_std
returns an error.
pub fn from_chrono(duration: Duration) -> FloatDuration
[src]
pub fn from_chrono(duration: Duration) -> FloatDuration
Create a FloatDuration
object from a chrono::Duration
.
chrono::Duration
does not provide a way to access sub-millisecond
precision if the duration is too large to be entirely represented as a single
value. Thus, if the absolute value of the total number of nanoseconds is
greater than i64::MAX
, only millisecond precision will be captured.
Equivalent to using FloatDuration::from(duration)
Trait Implementations
impl FromDuration<Duration> for FloatDuration
[src]
impl FromDuration<Duration> for FloatDuration
type Error = ()
fn from_duration(from: Duration) -> Result<FloatDuration, ()>
[src]
fn from_duration(from: Duration) -> Result<FloatDuration, ()>
impl FromDuration<Duration> for FloatDuration
[src]
impl FromDuration<Duration> for FloatDuration
type Error = ()
fn from_duration(from: Duration) -> Result<FloatDuration, ()>
[src]
fn from_duration(from: Duration) -> Result<FloatDuration, ()>
impl FromDuration<FloatDuration> for Duration
[src]
impl FromDuration<FloatDuration> for Duration
type Error = OutOfRangeError
fn from_duration(from: FloatDuration) -> Result<Duration, OutOfRangeError>
[src]
fn from_duration(from: FloatDuration) -> Result<Duration, OutOfRangeError>
impl FromDuration<FloatDuration> for Duration
[src]
impl FromDuration<FloatDuration> for Duration
type Error = OutOfRangeError
fn from_duration(from: FloatDuration) -> Result<Duration, OutOfRangeError>
[src]
fn from_duration(from: FloatDuration) -> Result<Duration, OutOfRangeError>
impl PartialOrd<FloatDuration> for FloatDuration
[src]
impl PartialOrd<FloatDuration> for FloatDuration
fn partial_cmp(&self, other: &FloatDuration) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &FloatDuration) -> Option<Ordering>
fn lt(&self, other: &FloatDuration) -> bool
[src]
fn lt(&self, other: &FloatDuration) -> bool
fn le(&self, other: &FloatDuration) -> bool
[src]
fn le(&self, other: &FloatDuration) -> bool
fn gt(&self, other: &FloatDuration) -> bool
[src]
fn gt(&self, other: &FloatDuration) -> bool
fn ge(&self, other: &FloatDuration) -> bool
[src]
fn ge(&self, other: &FloatDuration) -> bool
impl Default for FloatDuration
[src]
impl Default for FloatDuration
fn default() -> FloatDuration
[src]
fn default() -> FloatDuration
impl PartialEq<FloatDuration> for FloatDuration
[src]
impl PartialEq<FloatDuration> for FloatDuration
fn eq(&self, other: &FloatDuration) -> bool
[src]
fn eq(&self, other: &FloatDuration) -> bool
fn ne(&self, other: &FloatDuration) -> bool
[src]
fn ne(&self, other: &FloatDuration) -> bool
impl From<Duration> for FloatDuration
[src]
impl From<Duration> for FloatDuration
fn from(from: Duration) -> FloatDuration
[src]
fn from(from: Duration) -> FloatDuration
impl From<Duration> for FloatDuration
[src]
impl From<Duration> for FloatDuration
fn from(from: Duration) -> FloatDuration
[src]
fn from(from: Duration) -> FloatDuration
impl Clone for FloatDuration
[src]
impl Clone for FloatDuration
fn clone(&self) -> FloatDuration
[src]
fn clone(&self) -> FloatDuration
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for FloatDuration
[src]
impl Copy for FloatDuration
impl Display for FloatDuration
[src]
impl Display for FloatDuration
impl Debug for FloatDuration
[src]
impl Debug for FloatDuration
impl Add<FloatDuration> for FloatDuration
[src]
impl Add<FloatDuration> for FloatDuration
type Output = FloatDuration
The resulting type after applying the +
operator.
fn add(self, rhs: FloatDuration) -> FloatDuration
[src]
fn add(self, rhs: FloatDuration) -> FloatDuration
impl Sub<FloatDuration> for FloatDuration
[src]
impl Sub<FloatDuration> for FloatDuration
type Output = FloatDuration
The resulting type after applying the -
operator.
fn sub(self, rhs: FloatDuration) -> FloatDuration
[src]
fn sub(self, rhs: FloatDuration) -> FloatDuration
impl Mul<f64> for FloatDuration
[src]
impl Mul<f64> for FloatDuration
type Output = FloatDuration
The resulting type after applying the *
operator.
fn mul(self, rhs: f64) -> FloatDuration
[src]
fn mul(self, rhs: f64) -> FloatDuration
impl Mul<FloatDuration> for f64
[src]
impl Mul<FloatDuration> for f64
type Output = FloatDuration
The resulting type after applying the *
operator.
fn mul(self, rhs: FloatDuration) -> FloatDuration
[src]
fn mul(self, rhs: FloatDuration) -> FloatDuration
impl Div<f64> for FloatDuration
[src]
impl Div<f64> for FloatDuration
type Output = FloatDuration
The resulting type after applying the /
operator.
fn div(self, rhs: f64) -> FloatDuration
[src]
fn div(self, rhs: f64) -> FloatDuration
impl Div<FloatDuration> for FloatDuration
[src]
impl Div<FloatDuration> for FloatDuration
type Output = f64
The resulting type after applying the /
operator.
fn div(self, rhs: FloatDuration) -> f64
[src]
fn div(self, rhs: FloatDuration) -> f64
impl Neg for FloatDuration
[src]
impl Neg for FloatDuration
type Output = FloatDuration
The resulting type after applying the -
operator.
fn neg(self) -> FloatDuration
[src]
fn neg(self) -> FloatDuration
impl AddAssign<FloatDuration> for FloatDuration
[src]
impl AddAssign<FloatDuration> for FloatDuration
fn add_assign(&mut self, rhs: FloatDuration)
[src]
fn add_assign(&mut self, rhs: FloatDuration)
impl SubAssign<FloatDuration> for FloatDuration
[src]
impl SubAssign<FloatDuration> for FloatDuration
fn sub_assign(&mut self, rhs: FloatDuration)
[src]
fn sub_assign(&mut self, rhs: FloatDuration)
impl MulAssign<f64> for FloatDuration
[src]
impl MulAssign<f64> for FloatDuration
fn mul_assign(&mut self, rhs: f64)
[src]
fn mul_assign(&mut self, rhs: f64)
impl DivAssign<f64> for FloatDuration
[src]
impl DivAssign<f64> for FloatDuration
fn div_assign(&mut self, rhs: f64)
[src]
fn div_assign(&mut self, rhs: f64)
impl Sum<FloatDuration> for FloatDuration
[src]
impl Sum<FloatDuration> for FloatDuration
fn sum<I>(iter: I) -> FloatDuration where
I: Iterator<Item = FloatDuration>,
[src]
fn sum<I>(iter: I) -> FloatDuration where
I: Iterator<Item = FloatDuration>,
impl<'a> Sum<&'a FloatDuration> for FloatDuration
[src]
impl<'a> Sum<&'a FloatDuration> for FloatDuration
fn sum<I>(iter: I) -> FloatDuration where
I: Iterator<Item = &'a FloatDuration>,
[src]
fn sum<I>(iter: I) -> FloatDuration where
I: Iterator<Item = &'a FloatDuration>,
impl ApproxEq for FloatDuration
[src]
impl ApproxEq for FloatDuration
type Epsilon = f64
Used for specifying relative comparisons.
fn default_epsilon() -> f64
[src]
fn default_epsilon() -> f64
fn default_max_relative() -> f64
[src]
fn default_max_relative() -> f64
fn default_max_ulps() -> u32
[src]
fn default_max_ulps() -> u32
fn relative_eq(
&self,
other: &FloatDuration,
epsilon: f64,
max_relative: f64
) -> bool
[src]
fn relative_eq(
&self,
other: &FloatDuration,
epsilon: f64,
max_relative: f64
) -> bool
fn ulps_eq(&self, other: &FloatDuration, epsilon: f64, max_ulps: u32) -> bool
[src]
fn ulps_eq(&self, other: &FloatDuration, epsilon: f64, max_ulps: u32) -> bool
fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of ApproxEq::relative_eq
.
fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
[src]
fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
The inverse of ApproxEq::ulps_eq
.
impl Serialize for FloatDuration
[src]
impl Serialize for FloatDuration
impl<'de> Deserialize<'de> for FloatDuration
[src]
impl<'de> Deserialize<'de> for FloatDuration
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Auto Trait Implementations
impl Send for FloatDuration
impl Send for FloatDuration
impl Sync for FloatDuration
impl Sync for FloatDuration
Blanket Implementations
impl<T, U> IntoDuration for T where
U: FromDuration<T>,
[src]
impl<T, U> IntoDuration for T where
U: FromDuration<T>,
type Error = <U as FromDuration<T>>::Error
fn into_duration(Self) -> Result<U, <U as FromDuration<T>>::Error>
[src]
fn into_duration(Self) -> Result<U, <U as FromDuration<T>>::Error>
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
impl<T> ToString for T where
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,