Crate cicero_cache

Crate cicero_cache 

Source
Expand description

§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
    fs::create_dir_all(output_path.parent().unwrap())?;
    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.

Structs§

Output
Allows defining a cached file output and when it should be rebuilt.