Skip to content

Commit 9eb4b53

Browse files
committed
refactor(materialized_artifact): rename ensure_in -> materialize_in
The verb mirrors the crate name and makes the value-add over `include_bytes!` obvious at the call site.
1 parent a2d7f86 commit 9eb4b53

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

crates/fspy/src/unix/macos_artifacts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod tests {
1414
#[test]
1515
fn coreutils_functions() {
1616
let tmpdir = tempfile::tempdir().unwrap();
17-
let coreutils_path = COREUTILS_BINARY.ensure_in(&tmpdir, "", true).unwrap();
17+
let coreutils_path = COREUTILS_BINARY.materialize_in(&tmpdir, "", true).unwrap();
1818
let output = Command::new(coreutils_path).arg("--list").output().unwrap();
1919
let mut expected_functions: Vec<&str> = output
2020
.stdout

crates/fspy/src/unix/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl SpyImpl {
4949

5050
const PRELOAD_CDYLIB: Artifact = artifact!("fspy_preload");
5151

52-
let preload_cdylib_path = PRELOAD_CDYLIB.ensure_in(dir, ".dylib", false)?;
52+
let preload_cdylib_path = PRELOAD_CDYLIB.materialize_in(dir, ".dylib", false)?;
5353
preload_cdylib_path.as_path().into()
5454
};
5555

@@ -58,8 +58,8 @@ impl SpyImpl {
5858
preload_path,
5959
#[cfg(target_os = "macos")]
6060
artifacts: {
61-
let coreutils_path = macos_artifacts::COREUTILS_BINARY.ensure_in(dir, "", true)?;
62-
let bash_path = macos_artifacts::OILS_BINARY.ensure_in(dir, "", true)?;
61+
let coreutils_path = macos_artifacts::COREUTILS_BINARY.materialize_in(dir, "", true)?;
62+
let bash_path = macos_artifacts::OILS_BINARY.materialize_in(dir, "", true)?;
6363
Artifacts {
6464
bash_path: bash_path.as_path().into(),
6565
coreutils_path: coreutils_path.as_path().into(),

crates/fspy/src/windows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct SpyImpl {
5151

5252
impl SpyImpl {
5353
pub fn init_in(path: &Path) -> io::Result<Self> {
54-
let dll_path = INTERPOSE_CDYLIB.ensure_in(path, ".dll", false)?;
54+
let dll_path = INTERPOSE_CDYLIB.materialize_in(path, ".dll", false)?;
5555

5656
let wide_dll_path = dll_path.as_os_str().encode_wide().collect::<Vec<u16>>();
5757
let mut ansi_dll_path =

crates/materialized_artifact/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
//! but we want to ship a single executable. `materialized_artifact` embeds
66
//! the file content as a `&'static [u8]` at compile time via the
77
//! [`artifact!`] macro (same as `include_bytes!`), and
8-
//! [`Artifact::ensure_in`] writes it out to disk when first needed — that
8+
//! [`Artifact::materialize_in`] writes it out to disk when first needed — that
99
//! materialization step is the value-add over a bare `include_bytes!`.
1010
//!
1111
//! Materialized files are named `{name}_{hash}{suffix}` in the caller-chosen
1212
//! directory. The hash (computed at build time by
1313
//! `materialized_artifact_build::register`) gives three properties without
1414
//! any coordination between processes:
1515
//!
16-
//! - **No repeated writes.** [`Artifact::ensure_in`] returns the existing
16+
//! - **No repeated writes.** [`Artifact::materialize_in`] returns the existing
1717
//! path if the file is already there; repeated calls and re-runs skip I/O.
1818
//! - **Correctness.** Two binaries with different embedded content produce
1919
//! different filenames, so a stale file from an older build is never
@@ -29,7 +29,7 @@ use std::{
2929
};
3030

3131
/// A file embedded into the executable at compile time. Construct with
32-
/// [`artifact!`]; materialize to disk with [`Artifact::ensure_in`]. See the
32+
/// [`artifact!`]; materialize to disk with [`Artifact::materialize_in`]. See the
3333
/// [crate docs] for the design rationale.
3434
///
3535
/// [crate docs]: crate
@@ -82,7 +82,7 @@ impl Artifact {
8282
/// Returns an error if the directory can't be read/written, the stat
8383
/// fails for any reason other than not-found, or the temp-file rename
8484
/// fails and the destination still doesn't exist.
85-
pub fn ensure_in(
85+
pub fn materialize_in(
8686
&self,
8787
dir: impl AsRef<Path>,
8888
suffix: &str,

crates/materialized_artifact_build/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub const ENV_PREFIX: &str = "MATERIALIZED_ARTIFACT_";
1515
/// these at compile time via `include_bytes!(env!(…))` and `env!(…)`.
1616
///
1717
/// `name` is used both as the env-var key and as the on-disk filename prefix
18-
/// (in `Artifact::ensure_in`), so it must be a valid identifier-like string
18+
/// (in `Artifact::materialize_in`), so it must be a valid identifier-like string
1919
/// that matches the one passed to `artifact!`.
2020
///
2121
/// # Panics

0 commit comments

Comments
 (0)