job-dispatcher

Crates.iojob-dispatcher
lib.rsjob-dispatcher
version0.4.1
created_at2022-09-07 10:01:44.359022+00
updated_at2022-09-24 18:04:16.880295+00
descriptionRust crate to execute jobs in an async way
homepagehttps://github.com/sn99/job-dispatcher
repository
max_upload_size
id660275
size9,247
Dilawar Singh (dilawar)

documentation

README

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!

Commit count: 0

cargo fmt