pub struct Task<T, E = Error> {
    pub f: fn(_: Event<'_, T>) -> Result<(), E>,
    pub hz: f32,
    pub max_time_micros: u16,
    pub is_high_priority: bool,
    pub last_run: u16,
}
Expand description

A task to run at specific frequency

Fields

f: fn(_: Event<'_, T>) -> Result<(), E>

The function to run.

hz: f32

The desired frequency (in hz) to run the task.

max_time_micros: u16

The max time for this task (in microseconds).

is_high_priority: bool

Determines if this task should be run every time the scheduler loops.

last_run: u16

The last tick this task was ran.

Implementations

Create a new task from the function to run.

Create a new high priority task from the function to run.

Builder method to set hz and return self

Builder method to set max_time_micros and return self

Builder method to set is_high_priority and return self

Calculate the desired ticks between each run of the task

If this task is ready returns the ticks elapsed since the last run. Otherwise this returns None.

Run this task at the current tick.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.