workspacer-watch-and-reload

Crates.ioworkspacer-watch-and-reload
lib.rsworkspacer-watch-and-reload
version0.1.3
created_at2025-04-01 21:07:33.807942+00
updated_at2025-07-13 04:29:07.751714+00
descriptionAn asynchronous Rust crate for watching file changes and reloading Rust workspaces and crates. Detects changes in Cargo.toml and src/, executing custom rebuilds or tests.
homepage
repository
max_upload_size
id1615580
size188,971
(klebs6)

documentation

README

workspacer-watch-and-reload

Overview

workspacer-watch-and-reload is a Rust crate enabling efficient file-watching and automatic reloading capabilities within Rust workspaces and crates. Built with an emphasis on asynchronous execution, this crate ensures high responsiveness to file system changes, facilitating automated rebuilds or tests upon detection of significant modifications.

Features

  • Asynchronous Operation: Leverages async Rust for non-blocking file monitoring, allowing seamless integration into existing async workflows.
  • Granular Change Detection: Effectively determines and responds to relevant changes, specifically within Cargo.toml and the src/ directories.
  • Flexible Error Handling: Employs robust error typing for precise exception management.
  • Dynamic Command Execution: Interfaces with user-supplied CommandRunner implementations to execute custom rebuild or test commands upon file changes.

Usage

Trait: WatchAndReload

Implement the WatchAndReload trait to define how a concrete type should respond to filesystem changes.

#[async_trait]
impl WatchAndReload for MyCrate {
    type Error = MyError;
    async fn watch_and_reload<'a>(&self, tx: Option<mpsc::Sender<Result<(), Self::Error>>>, runner: Arc<dyn CommandRunner + Send + Sync + 'a>, cancel_token: CancellationToken) -> Result<(), Self::Error> {
        // Implementation
    }
    async fn is_relevant_change(&self, path: &Path) -> bool {
        // Implementation
    }
}

Functions

  • setup_file_watching Initialize and configure file watching capabilities.
  • watch_loop Continuously monitors for changes, executing the necessary rebuilds or tests.

Installation

Add the following to your Cargo.toml:

[dependencies]
workspacer-watch-and-reload = "0.1.0"

License

This project is licensed under the MIT License.

Commit count: 0

cargo fmt