| Crates.io | work-manager |
| lib.rs | work-manager |
| version | 0.1.3 |
| created_at | 2025-11-20 11:51:28.734163+00 |
| updated_at | 2025-12-18 12:36:43.202698+00 |
| description | A library for managing asynchronous work tasks. |
| homepage | https://github.com/luukgoossen/work-manager |
| repository | https://github.com/luukgoossen/work-manager |
| max_upload_size | |
| id | 1941841 |
| size | 28,035 |
work-manager is a Rust library designed to simplify the management of asynchronous tasks. It allows you to define Jobs, chain them into Sequences, and schedule them using a WorkManager.
Job trait to define units of work..then(), passing results from one to the next.WorkManager to enqueue one-off or periodic jobs.Add this to your Cargo.toml:
[dependencies]
work-manager = "0.1.0"
tokio = { version = "1", features = ["rt", "time", "macros"] }
use work_manager::{Job, WorkManager};
use std::time::Duration;
struct PrintJob {
message: String,
}
impl Job for PrintJob {
type Output = ();
type Error = std::io::Error;
async fn run(self) -> Result<Self::Output, Self::Error> {
println!("{}", self.message);
Ok(())
}
}
#[tokio::main]
async fn main() {
let mut manager = WorkManager::new();
// Enqueue a single job
manager.enqueue("print_hello", PrintJob { message: "Hello".into() }, false);
// Enqueue a periodic job
manager.enqueue_periodic(
"print_tick",
PrintJob { message: "Tick".into() },
Duration::from_secs(1),
false,
false
);
}
This project is licensed under the MIT License.