| Crates.io | cicero_cache |
| lib.rs | cicero_cache |
| version | 0.8.1 |
| created_at | 2025-11-08 18:22:27.810973+00 |
| updated_at | 2026-01-18 20:04:47.202115+00 |
| description | Rebuild files only when needed. |
| homepage | |
| repository | https://codeberg.org/trem/cicero/ |
| max_upload_size | |
| id | 1923125 |
| size | 50,370 |
Rebuild files only when needed.
use std::{fs, path::PathBuf};
let output_path = PathBuf::from("my/build/result.txt");
cicero_cache::Output::from(output_path.clone()).rebuild_on_change([
PathBuf::from("my/build/input.csv"),
], || {
// Your build code here
if let Some(parent_dir) = output_path.parent() {
fs::create_dir_all(parent_dir)?;
}
fs::File::create(output_path)?;
Ok(())
});
List a set of input files and an output file or directory. When any of these change, it will run the build code you provide in the closure and store the new state after execution.
This is primarily useful when you have complex logic for building parts of your distribution, which can be skipped when none of the inputs changed.
External build tools, such as Cargo, Cross or Trunk, will typically bring their own caching, so wrapping their calls is typically not worth the trouble.