debouncer

Crates.iodebouncer
lib.rsdebouncer
version0.1.3
sourcesrc
created_at2024-08-03 14:25:06.951301
updated_at2024-08-05 01:12:50.238458
descriptionA simple debouncer for Rust
homepage
repositoryhttps://github.com/akihiro-suzuk1/debouncer
max_upload_size
id1324355
size8,516
Akihiro_Suzuki (akihiro-suzuk1)

documentation

README

Debouncer

A simple debouncer for Rust, using Tokio for async timing. This crate provides a mechanism to debounce function calls, ensuring that only the last call within a specified delay is executed.

Installation

Add this to your Cargo.toml:

[dependencies]
debouncer = "0.1.0"
tokio = { version = "1", features = ["full"] }

Usage

Here’s a basic example demonstrating how to use the Debouncer:

use tokio::time::Duration;
use debouncer::Debouncer;

#[tokio::main]
async fn main() {
    let debouncer = Debouncer::new(Duration::from_secs(1));
    let counter = Arc::new(Mutex::new(0));

    let counter_clone = Arc::clone(&counter);
    debouncer.call(move || {
        async move {
            let mut num = counter_clone.lock().unwrap();
            *num += 1;
        }
    }).await;
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

1.	Fork the repository
2.	Create your feature branch (git checkout -b feature/your-feature)
3.	Commit your changes (git commit -am 'Add some feature')
4.	Push to the branch (git push origin feature/your-feature)
5.	Create a new Pull Request

License

This project is licensed under the MIT or Apache-2.0 License. See the LICENSE file for details.

Commit count: 0

cargo fmt