[−][src]Struct game_time::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 FloatDurationpub fn years(years: f64) -> FloatDuration[src]
pub fn years(years: f64) -> FloatDurationCreate 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) -> FloatDurationCreate a new FloatDuration representing a number of days.
pub fn hours(hours: f64) -> FloatDuration[src]
pub fn hours(hours: f64) -> FloatDurationCreate a new FloatDuration representing a number of hours.
pub fn minutes(mins: f64) -> FloatDuration[src]
pub fn minutes(mins: f64) -> FloatDurationCreate a new FloatDuration representing a number of minutes.
pub fn seconds(secs: f64) -> FloatDuration[src]
pub fn seconds(secs: f64) -> FloatDurationCreate a new FloatDuration representing a number of seconds.
pub fn milliseconds(millis: f64) -> FloatDuration[src]
pub fn milliseconds(millis: f64) -> FloatDurationCreate a new FloatDuration representing a number of milliseconds.
pub fn microseconds(micros: f64) -> FloatDuration[src]
pub fn microseconds(micros: f64) -> FloatDurationCreate a new FloatDuration representing a number of microseconds.
pub fn nanoseconds(nanos: f64) -> FloatDuration[src]
pub fn nanoseconds(nanos: f64) -> FloatDurationCreate a new FloatDuration representing a number of nanoseconds.
pub fn as_years(&self) -> f64[src]
pub fn as_years(&self) -> f64Return 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) -> f64Return the total number of fractional days represented by the FloatDuration.
pub fn as_hours(&self) -> f64[src]
pub fn as_hours(&self) -> f64Return the total number of fractional hours represented by the FloatDuration.
pub fn as_minutes(&self) -> f64[src]
pub fn as_minutes(&self) -> f64Return the total number of fractional minutes represented by the FloatDuration.
pub fn as_seconds(&self) -> f64[src]
pub fn as_seconds(&self) -> f64Return the total number of fractional seconds represented by the FloatDuration.
pub fn as_milliseconds(&self) -> f64[src]
pub fn as_milliseconds(&self) -> f64Return the total number of fractional milliseconds represented by the FloatDuration.
pub fn as_microseconds(&self) -> f64[src]
pub fn as_microseconds(&self) -> f64Return the total number of fractional microseconds represented by the FloatDuration.
pub fn as_nanoseconds(&self) -> f64[src]
pub fn as_nanoseconds(&self) -> f64Return the total number of fractional nanoseconds represented by the FloatDuration.
pub fn abs(self) -> FloatDuration[src]
pub fn abs(self) -> FloatDurationCompute the absolute value of this duration.
pub fn zero() -> FloatDuration[src]
pub fn zero() -> FloatDurationReturn a new FloatDuration that represents zero elapsed time.
pub fn is_zero(&self) -> bool[src]
pub fn is_zero(&self) -> boolReturns true is this duration represents zero elapsed time (equals FloatDuration::zero()).
pub fn is_positive(&self) -> bool[src]
pub fn is_positive(&self) -> boolReturns true if the FloatDuration holds a positive amount of time.
pub fn is_negative(&self) -> bool[src]
pub fn is_negative(&self) -> boolReturns true if the FloatDuration holds a negative amount of time.
pub fn signum(&self) -> f64[src]
pub fn signum(&self) -> f64Return a number that represents the sign of self.
- 1.0 if the value is positive,
+0.0orINFINITY - -1.0 if the value is negative,
-0.0orNEG_INFINITY NANif the value isNAN
pub fn max(self, other: FloatDuration) -> FloatDuration[src]
pub fn max(self, other: FloatDuration) -> FloatDurationReturn the maximum of two durations.
pub fn min(self, other: FloatDuration) -> FloatDuration[src]
pub fn min(self, other: FloatDuration) -> FloatDurationReturn the minimum of two durations.
pub fn min_value() -> FloatDuration[src]
pub fn min_value() -> FloatDurationReturn a new FloatDuration with the minimum possible value.
pub fn max_value() -> FloatDuration[src]
pub fn max_value() -> FloatDurationReturn 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) -> FloatDurationCreate a FloatDuration object from a std::time::Duration.
Equivalent to using FloatDuration::from(duration)
impl FloatDuration[src]
impl FloatDurationpub 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) -> FloatDurationCreate 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<'de> Deserialize<'de> for FloatDuration[src]
impl<'de> Deserialize<'de> for FloatDurationfn deserialize<D>(
deserializer: D
) -> Result<FloatDuration, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>, [src]
fn deserialize<D>(
deserializer: D
) -> Result<FloatDuration, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>, impl Serialize for FloatDuration[src]
impl Serialize for FloatDurationfn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer, [src]
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer, impl Sub<FloatDuration> for FloatDuration[src]
impl Sub<FloatDuration> for FloatDurationtype Output = FloatDuration
The resulting type after applying the - operator.
fn sub(self, rhs: FloatDuration) -> FloatDuration[src]
fn sub(self, rhs: FloatDuration) -> FloatDurationimpl FromDuration<Duration> for FloatDuration[src]
impl FromDuration<Duration> for FloatDurationtype 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 FloatDurationtype Error = ()
fn from_duration(from: Duration) -> Result<FloatDuration, ()>[src]
fn from_duration(from: Duration) -> Result<FloatDuration, ()>impl From<Duration> for FloatDuration[src]
impl From<Duration> for FloatDurationfn from(from: Duration) -> FloatDuration[src]
fn from(from: Duration) -> FloatDurationimpl From<Duration> for FloatDuration[src]
impl From<Duration> for FloatDurationfn from(from: Duration) -> FloatDuration[src]
fn from(from: Duration) -> FloatDurationimpl Debug for FloatDuration[src]
impl Debug for FloatDurationimpl PartialEq<FloatDuration> for FloatDuration[src]
impl PartialEq<FloatDuration> for FloatDurationfn eq(&self, other: &FloatDuration) -> bool[src]
fn eq(&self, other: &FloatDuration) -> boolfn ne(&self, other: &FloatDuration) -> bool[src]
fn ne(&self, other: &FloatDuration) -> boolimpl Mul<f64> for FloatDuration[src]
impl Mul<f64> for FloatDurationtype Output = FloatDuration
The resulting type after applying the * operator.
fn mul(self, rhs: f64) -> FloatDuration[src]
fn mul(self, rhs: f64) -> FloatDurationimpl DivAssign<f64> for FloatDuration[src]
impl DivAssign<f64> for FloatDurationfn div_assign(&mut self, rhs: f64)[src]
fn div_assign(&mut self, rhs: f64)impl Clone for FloatDuration[src]
impl Clone for FloatDurationfn clone(&self) -> FloatDuration[src]
fn clone(&self) -> FloatDurationfn 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 ApproxEq for FloatDuration[src]
impl ApproxEq for FloatDurationtype Epsilon = f64
Used for specifying relative comparisons.
fn default_epsilon() -> f64[src]
fn default_epsilon() -> f64fn default_max_relative() -> f64[src]
fn default_max_relative() -> f64fn default_max_ulps() -> u32[src]
fn default_max_ulps() -> u32fn relative_eq(
&self,
other: &FloatDuration,
epsilon: f64,
max_relative: f64
) -> bool[src]
fn relative_eq(
&self,
other: &FloatDuration,
epsilon: f64,
max_relative: f64
) -> boolfn ulps_eq(&self, other: &FloatDuration, epsilon: f64, max_ulps: u32) -> bool[src]
fn ulps_eq(&self, other: &FloatDuration, epsilon: f64, max_ulps: u32) -> boolfn 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
) -> boolThe 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) -> boolThe inverse of ApproxEq::ulps_eq.
impl Div<FloatDuration> for FloatDuration[src]
impl Div<FloatDuration> for FloatDurationtype Output = f64
The resulting type after applying the / operator.
fn div(self, rhs: FloatDuration) -> f64[src]
fn div(self, rhs: FloatDuration) -> f64impl Div<f64> for FloatDuration[src]
impl Div<f64> for FloatDurationtype Output = FloatDuration
The resulting type after applying the / operator.
fn div(self, rhs: f64) -> FloatDuration[src]
fn div(self, rhs: f64) -> FloatDurationimpl Display for FloatDuration[src]
impl Display for FloatDurationimpl AddAssign<FloatDuration> for FloatDuration[src]
impl AddAssign<FloatDuration> for FloatDurationfn add_assign(&mut self, rhs: FloatDuration)[src]
fn add_assign(&mut self, rhs: FloatDuration)impl PartialOrd<FloatDuration> for FloatDuration[src]
impl PartialOrd<FloatDuration> for FloatDurationfn 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) -> boolfn le(&self, other: &FloatDuration) -> bool[src]
fn le(&self, other: &FloatDuration) -> boolfn gt(&self, other: &FloatDuration) -> bool[src]
fn gt(&self, other: &FloatDuration) -> boolfn ge(&self, other: &FloatDuration) -> bool[src]
fn ge(&self, other: &FloatDuration) -> boolimpl MulAssign<f64> for FloatDuration[src]
impl MulAssign<f64> for FloatDurationfn mul_assign(&mut self, rhs: f64)[src]
fn mul_assign(&mut self, rhs: f64)impl SubAssign<FloatDuration> for FloatDuration[src]
impl SubAssign<FloatDuration> for FloatDurationfn sub_assign(&mut self, rhs: FloatDuration)[src]
fn sub_assign(&mut self, rhs: FloatDuration)impl Add<FloatDuration> for FloatDuration[src]
impl Add<FloatDuration> for FloatDurationtype Output = FloatDuration
The resulting type after applying the + operator.
fn add(self, rhs: FloatDuration) -> FloatDuration[src]
fn add(self, rhs: FloatDuration) -> FloatDurationimpl Sum<FloatDuration> for FloatDuration[src]
impl Sum<FloatDuration> for FloatDurationfn 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 FloatDurationfn 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 Neg for FloatDuration[src]
impl Neg for FloatDurationtype Output = FloatDuration
The resulting type after applying the - operator.
fn neg(self) -> FloatDuration[src]
fn neg(self) -> FloatDurationimpl Default for FloatDuration[src]
impl Default for FloatDurationfn default() -> FloatDuration[src]
fn default() -> FloatDurationimpl Copy for FloatDuration[src]
impl Copy for FloatDurationAuto Trait Implementations
impl Send for FloatDuration
impl Send for FloatDurationimpl Sync for FloatDuration
impl Sync for FloatDurationBlanket Implementations
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 Timpl<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) -> TypeIdimpl<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 Timpl<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> DeserializeOwned for T where
T: Deserialize<'de>, [src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,