Struct AsyncCustomScheduler

Source
pub struct AsyncCustomScheduler<INSTANT, SLEEPER> { /* private fields */ }

Implementations§

Source§

impl<INSTANT, SLEEPER> AsyncCustomScheduler<INSTANT, SLEEPER>
where INSTANT: Instant, SLEEPER: AsyncSleeper,

Source

pub fn new(target_hz: f32) -> Self
where SLEEPER: Default,

Constructs a new AsyncCustomScheduler struct that can schedule tasks at the given frequency target_hz.

Source

pub fn with_sleeper(target_hz: f32, sleeper: SLEEPER) -> Self

Constructs a new AsyncCustomScheduler struct that can schedule tasks at the given frequency target_hz.

Source

pub fn set_hz(&mut self, new_target_hz: f32)

Allows you to change the frequency at which the scheduler tries to run tasks.

Source

pub fn hz(&self) -> f32

Returns the frequency the AsyncCustomScheduler is currently set to.

Source

pub async fn loop_forever(&mut self, task: impl FnMut()) -> !

Lets you run a task at a fixed interval, forever.

Source

pub async fn loop_while_true(&mut self, task: impl FnMut() -> bool)

Lets you run a task at a fixed interval. Will break when the function returns false.

Source

pub async fn loop_until_err<T>( &mut self, task: impl FnMut() -> Result<T, Box<dyn Error>>, ) -> Box<dyn Error>

Lets you run a task at a fixed interval. Will break when the function returns a result of Err variant.

Source

pub async fn sleep_until_next_frame(&mut self)

Can be called manually to sleep until the next scheduled frame.

Valuable for when you’d like to avoid having to pass values into a closure, or would like more control over loop flow.

Trait Implementations§

Source§

impl<INSTANT: Clone, SLEEPER: Clone> Clone for AsyncCustomScheduler<INSTANT, SLEEPER>

Source§

fn clone(&self) -> AsyncCustomScheduler<INSTANT, SLEEPER>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<INSTANT: Debug, SLEEPER: Debug> Debug for AsyncCustomScheduler<INSTANT, SLEEPER>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<INSTANT, SLEEPER> Default for AsyncCustomScheduler<INSTANT, SLEEPER>
where INSTANT: Instant, SLEEPER: AsyncSleeper + Default,

Source§

fn default() -> Self

assumes a default hz of 60

Source§

impl<INSTANT: Hash, SLEEPER: Hash> Hash for AsyncCustomScheduler<INSTANT, SLEEPER>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<INSTANT: Copy, SLEEPER: Copy> Copy for AsyncCustomScheduler<INSTANT, SLEEPER>

Auto Trait Implementations§

§

impl<INSTANT, SLEEPER> Freeze for AsyncCustomScheduler<INSTANT, SLEEPER>
where INSTANT: Freeze, SLEEPER: Freeze,

§

impl<INSTANT, SLEEPER> RefUnwindSafe for AsyncCustomScheduler<INSTANT, SLEEPER>
where INSTANT: RefUnwindSafe, SLEEPER: RefUnwindSafe,

§

impl<INSTANT, SLEEPER> Send for AsyncCustomScheduler<INSTANT, SLEEPER>
where INSTANT: Send, SLEEPER: Send,

§

impl<INSTANT, SLEEPER> Sync for AsyncCustomScheduler<INSTANT, SLEEPER>
where INSTANT: Sync, SLEEPER: Sync,

§

impl<INSTANT, SLEEPER> Unpin for AsyncCustomScheduler<INSTANT, SLEEPER>
where INSTANT: Unpin, SLEEPER: Unpin,

§

impl<INSTANT, SLEEPER> UnwindSafe for AsyncCustomScheduler<INSTANT, SLEEPER>
where INSTANT: UnwindSafe, SLEEPER: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> ColorType for T
where T: Debug + Default + Copy,