white_rabbit

Crates.iowhite_rabbit
lib.rswhite_rabbit
version0.1.1
sourcesrc
created_at2019-05-09 12:44:30.27526
updated_at2019-05-09 13:34:43.661431
descriptionTask scheduler, allowing timed execution, repeated or not.
homepage
repositoryhttps://github.com/lakelezz/white_rabbit.git
max_upload_size
id133067
size21,243
(Lakelezz)

documentation

https://docs.rs/white_rabbit

README

ci-badge docs-badge rust badge crates.io version

“I'm late! I'm late! For a very important date!”

by “The White Rabbit” 『Alice's Adventures in Wonderland』

About

white_rabbit schedules your tasks and can repeat them!

One funny use case are chat bots, e.g. a remind me-command that might be repeated after a user-specified time.

We are using chrono's DateTime<Utc>, enabling you to serialise and thus backup currently running tasks, in case you want to shutdown/restart your application, constructing a new scheduler is doable. However, please make sure your internal clock is synced.

Everyone is welcome to contribute, check out the CONTRIBUTING.md for further guidance.

Example

Let's have a look at a code-example:

use white_rabbit::{DateResult, Duration, Scheduler};

fn main() {
    let mut scheduler = Scheduler::new(4);

    scheduler.add_task_duration(Duration::seconds(5), |_| {
        println!("I'm here!");

        DateResult::Done
    });
}

Precision

The scheduler sleeps when unneeded. Due to preemption or different implementations across operating systems, it may occur that the scheduler will sleep longer than intended.

Be aware, an incorrect system clock may lead to tasks being run earlier or later.

Installation

Add this to your Cargo.toml:

[dependencies]
white_rabbit = "0.1.0"
Commit count: 9

cargo fmt