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]

[src]

Constructs a time value from a number of seconds.

[src]

Constructs a time value from a number of milliseconds.

[src]

Constructs a time value from a number of microseconds.

[src]

Returns the time value as a number of seconds.

[src]

Returns the time value as a number of milliseconds.

[src]

Returns the time value as a number of microseconds.

ZERO: Time = Time(sfTime{microseconds: 0,})

Predefined "zero" time value.

Trait Implementations

impl Copy for Time
[src]

impl Clone for Time
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Time
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for Time
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Eq for Time
[src]

impl PartialOrd for Time
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[src]

This method returns an Ordering between self and other. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the minimum of two values. Read more

impl Neg for Time
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl Add for Time
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl AddAssign for Time
[src]

[src]

Performs the += operation.

impl Sub for Time
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl SubAssign for Time
[src]

[src]

Performs the -= operation.

impl Mul<f32> for Time
[src]

The resulting type after applying the * operator.

[src]

Overload of binary * operator to scale a time value.

impl Mul<i64> for Time
[src]

The resulting type after applying the * operator.

[src]

Overload of binary * operator to scale a time value.

impl MulAssign<f32> for Time
[src]

[src]

Overload of binary *= operator to scale/assign a time value.

impl MulAssign<i64> for Time
[src]

[src]

Overload of binary *= operator to scale/assign a time value.

impl Div<f32> for Time
[src]

The resulting type after applying the / operator.

[src]

Overload of binary / operator to scale a time value.

impl Div<i64> for Time
[src]

The resulting type after applying the / operator.

[src]

Overload of binary / operator to scale a time value.

impl Div for Time
[src]

The resulting type after applying the / operator.

[src]

Overload of binary / operator to compute the ratio of two time values.

impl DivAssign<f32> for Time
[src]

[src]

Overload of binary /= operator to scale/assign a time value.

impl DivAssign<i64> for Time
[src]

[src]

Overload of binary /= operator to scale/assign a time value.

impl Rem for Time
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl RemAssign for Time
[src]

[src]

Performs the %= operation.