| Crates.io | rustycog |
| lib.rs | rustycog |
| version | 0.2.1 |
| created_at | 2025-05-22 07:44:08.394055+00 |
| updated_at | 2025-05-30 09:37:40.949628+00 |
| description | A synchronous task manager |
| homepage | |
| repository | https://www.github.com/Huggepugge1/RustyCog |
| max_upload_size | |
| id | 1684877 |
| size | 59,812 |
Effortless Task Management with Dynamic Execution
RustyCog is a lightweight task manager for Rust. It allows you to schedule cogs (Tasks), engage (executing) them and finally retrieve their results. Results can be retrieved at any time, either blocking or simply check back in a while to see if the cog has finished.
cargo add rustycog
use rustycog::{Machine, Cog};
let mut machine = Machine::powered(1);
let id0 = machine.insert_cog(Cog::new(|| 42));
let id1 = machine.insert_cog(Cog::new(|| {
println!("Running task...");
99
}));
println!("Result of cog 0: {:?}", machine.wait_for_result(id0).unwrap()); // Ok(42)
println!("Result of cog 1: {:?}", machine.wait_for_result(id1).unwrap()); // Ok(99)
use rustycog::{Machine, PrioCog};
// Cold = don't run immediatly
let mut machine = Machine::cold(1);
// Will run first!
let id0 = machine.insert_cog(PrioCog::new(|| 42), 0);
// Will run second!
let id1 = machine.insert_cog(PrioCog::new(|| {
println!("Running task...");
99
}, 1));
// Start running cogs
machine.power();
println!("Result of cog 0: {:?}", machine.wait_for_result(id0).unwrap()); // Ok(42)
println!("Result of cog 1: {:?}", machine.wait_for_result(id1).unwrap()); // Ok(99)
RustyCog provides a unique approach to task management in Rust, allowing you to manage tasks like futures without actually being asynchronous. Synchronous + asyncrhonous in one!
Contributions are welcome! Please open an issue to discuss your ideas, or fork the repo and open a pull request.
This project is licensed under the MIT License. See [LICENSE] for details.