Struct Timer

Source
pub struct Timer { /* private fields */ }
Expand description

The Timer struct calculates delta time and if fixed updates should be done to calculate the times, the crate’s stopwatch is used

Implementations§

Source§

impl Timer

Source

pub fn new() -> Self

Create a new timer object time since last fixed update is set to a high number on creation to get a fixed update on start

Source

pub fn time_since_start(&self) -> Duration

Get the time since start of the timer

Source

pub fn update_delta_time(&mut self)

update the delta time and time since start place this on the beginning of the loop

Source

pub fn update_fixed_time(&mut self)

update the time since last fixed update place this after update delta time this function is not required if no fixed update is used

Source

pub fn should_fixed_update(&self) -> bool

returns a bool if a fixed update should be done this function is not required if no fixed update is used

Source

pub fn set_fixed_interval(&mut self, fixed_interval: Duration)

set the interval of a fixed update in seconds this function is not required if no fixed update is used

Source

pub fn delta_time(&self) -> Duration

public getter for the delta time

Source

pub fn fixed_interval(&self) -> Duration

public getter for the delta fixed interval

Source

pub fn time_since_last_fixed(&self) -> Duration

public getter for the time since the last fixed update

Trait Implementations§

Source§

impl Default for Timer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for Timer

Source§

impl Sync for Timer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.