Welcome to the io-timer repository! This project offers a set of I/O-free Rust coroutines designed to efficiently manage timers. With a focus on simplicity and performance, io-timer allows you to create and manage timers without the overhead of I/O operations.
In modern applications, timers play a crucial role in scheduling tasks and managing delays. The io-timer library provides a lightweight and efficient solution for creating timers using Rust coroutines. By avoiding I/O operations, this library ensures high performance and low resource consumption.
- I/O-free: Operates without any I/O dependencies, making it lightweight.
- Coroutines: Utilizes Rust's coroutine capabilities for efficient task management.
- Simple API: Easy-to-use interface for creating and managing timers.
- Performance: Optimized for speed and low memory usage.
- Flexible: Supports various timer configurations to suit different use cases.
To use io-timer in your Rust project, add the following to your Cargo.toml
:
[dependencies]
io-timer = "0.1"
Then, run the following command to install the library:
cargo build
Here’s a quick guide on how to use io-timer in your project. First, import the library:
use io_timer::Timer;
Next, create a new timer:
let timer = Timer::new();
You can start the timer with a specified duration:
timer.start(5); // Starts a timer for 5 seconds
To check if the timer has finished, you can use:
if timer.is_finished() {
println!("Timer has finished!");
}
For more advanced usage, refer to the Examples section.
Here are a few examples to demonstrate how to use the io-timer library effectively.
use io_timer::Timer;
fn main() {
let timer = Timer::new();
timer.start(10); // Start a 10-second timer
while !timer.is_finished() {
// Do some work
}
println!("Timer finished!");
}
You can create multiple timers and manage them independently:
use io_timer::Timer;
fn main() {
let timer1 = Timer::new();
let timer2 = Timer::new();
timer1.start(5); // 5 seconds
timer2.start(10); // 10 seconds
while !timer1.is_finished() || !timer2.is_finished() {
if timer1.is_finished() {
println!("Timer 1 finished!");
}
if timer2.is_finished() {
println!("Timer 2 finished!");
}
}
}
You can also define custom actions when the timer finishes:
use io_timer::Timer;
fn main() {
let timer = Timer::new();
timer.start(3); // 3 seconds
while !timer.is_finished() {
// Wait for the timer to finish
}
on_timer_finished();
}
fn on_timer_finished() {
println!("Custom action: Timer finished!");
}
We welcome contributions to io-timer! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your changes to your fork.
- Submit a pull request.
Please ensure that your code follows the project's coding standards and includes appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for more details.
You can find the latest releases of io-timer here. Please download and execute the appropriate file for your system.
For any questions or feedback, feel free to reach out to the maintainer:
- Rohit Parteti
- GitHub Profile
Thank you for your interest in io-timer! We hope this library helps you manage timers efficiently in your Rust applications. For more updates, please check the Releases section regularly.