Struct sfml::system::Time
[−]
[src]
pub struct Time(_);
Represents a time value.
Time encapsulates a time value in a flexible way.
It allows to define a time value either as a number of seconds, milliseconds or microseconds. It also works the other way round: you can read a time value as either a number of seconds, milliseconds or microseconds.
By using such a flexible interface, the API doesn't impose any fixed type or resolution for time values, and let the user choose its own favorite representation.
Time values support the usual mathematical operations: you can add or subtract two times, multiply or divide a time by a number, compare two times, etc.
Since they represent a time span and not an absolute time value, times can also be negative.
Usage example
let t1 = Time::seconds(0.1); assert_eq!(t1.as_milliseconds(), 100); let t2 = Time::milliseconds(30); assert_eq!(t2.as_microseconds(), 30_000); let t3 = Time::microseconds(-800_000); assert_eq!(t3.as_seconds(), -0.8);
See also
Clock
Methods
impl Time
[src]
fn seconds(seconds: f32) -> Self
[src]
Constructs a time value from a number of seconds.
fn milliseconds(milliseconds: i32) -> Self
[src]
Constructs a time value from a number of milliseconds.
fn microseconds(microseconds: i64) -> Self
[src]
Constructs a time value from a number of microseconds.
fn as_seconds(&self) -> f32
[src]
Returns the time value as a number of seconds.
fn as_milliseconds(&self) -> i32
[src]
Returns the time value as a number of milliseconds.
fn as_microseconds(&self) -> i64
[src]
Returns the time value as a number of microseconds.
const ZERO: Time
ZERO: Time = Time(sfTime{microseconds: 0,})
Predefined "zero" time value.
Trait Implementations
impl Copy for Time
[src]
impl Clone for Time
[src]
fn clone(&self) -> Time
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Time
[src]
impl PartialEq for Time
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for Time
[src]
impl PartialOrd for Time
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for Time
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the minimum of two values. Read more
impl Neg for Time
[src]
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self
[src]
Performs the unary -
operation.
impl Add for Time
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
Performs the +
operation.
impl AddAssign for Time
[src]
fn add_assign(&mut self, rhs: Self)
[src]
Performs the +=
operation.
impl Sub for Time
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
Performs the -
operation.
impl SubAssign for Time
[src]
fn sub_assign(&mut self, rhs: Self)
[src]
Performs the -=
operation.
impl Mul<f32> for Time
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: f32) -> Self
[src]
Overload of binary * operator to scale a time value.
impl Mul<i64> for Time
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: i64) -> Self
[src]
Overload of binary * operator to scale a time value.
impl MulAssign<f32> for Time
[src]
fn mul_assign(&mut self, rhs: f32)
[src]
Overload of binary *= operator to scale/assign a time value.
impl MulAssign<i64> for Time
[src]
fn mul_assign(&mut self, rhs: i64)
[src]
Overload of binary *= operator to scale/assign a time value.
impl Div<f32> for Time
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: f32) -> Self
[src]
Overload of binary / operator to scale a time value.
impl Div<i64> for Time
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: i64) -> Self
[src]
Overload of binary / operator to scale a time value.
impl Div for Time
[src]
type Output = f32
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> f32
[src]
Overload of binary / operator to compute the ratio of two time values.
impl DivAssign<f32> for Time
[src]
fn div_assign(&mut self, rhs: f32)
[src]
Overload of binary /= operator to scale/assign a time value.
impl DivAssign<i64> for Time
[src]
fn div_assign(&mut self, rhs: i64)
[src]
Overload of binary /= operator to scale/assign a time value.
impl Rem for Time
[src]
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, rhs: Self) -> Self
[src]
Performs the %
operation.
impl RemAssign for Time
[src]
fn rem_assign(&mut self, rhs: Self)
[src]
Performs the %=
operation.