cicero_cache

Crates.iocicero_cache
lib.rscicero_cache
version0.8.1
created_at2025-11-08 18:22:27.810973+00
updated_at2026-01-18 20:04:47.202115+00
descriptionRebuild files only when needed.
homepage
repositoryhttps://codeberg.org/trem/cicero/
max_upload_size
id1923125
size50,370
(trem-rs)

documentation

README

Cicero Cache

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.

Commit count: 243

cargo fmt