#jobs #async-task #task #dispatch #check #async

job-dispatcher

Rust crate to execute jobs in an async way

5 releases (3 breaking)

0.4.1 Sep 24, 2022
0.4.0 Sep 14, 2022
0.3.0 Sep 11, 2022
0.2.0 Sep 10, 2022
0.1.0 Sep 7, 2022

#29 in #dispatch

MIT license

10KB
112 lines

job-dispatcher

Crates.io docs.rs

Rust crate to execute jobs/tasks in an async way

Example:-

use job_dispatcher::job::Job;

#[tokio::main]
async fn main() {
    let path = "C:\\Users\\sn99\\Downloads\\privacy-script.bat";

    let mut job = Job::new("trash", path);

    // start a job
    job.start();

    // check is the job is done (does not block)
    println!("Job done?: {:?}", job.try_wait());

    // wait for it to finish (will block), will error out if previous statement returns `Ok`, use `match` to handle them
    job.wait().await.expect("Job failed");

    println!("Job exited with code: {:?}", job.get_status());
}

LICENSE

Contribution

MIT licensed. Contributions are welcome!

Dependencies

~2–10MB
~95K SLoC