MCPcopy Create free account
hub / github.com/base/base / write_json

Method write_json

etc/systems/src/benchmark_cli.rs:643–652  ·  view source on GitHub ↗

Writes one JSON artifact and ensures its parent directory exists.

(path: &Path, value: &T, artifact: &str)

Source from the content-addressed store, hash-verified

641
642 /// Writes one JSON artifact and ensures its parent directory exists.
643 pub fn write_json<T: Serialize>(path: &Path, value: &T, artifact: &str) -> Result<()> {
644 let parent = path.parent().ok_or_else(|| {
645 eyre::eyre!("{artifact} path has no parent directory: {}", path.display())
646 })?;
647 fs::create_dir_all(parent).wrap_err_with(|| {
648 format!("failed to create {artifact} directory {}", parent.display())
649 })?;
650 fs::write(path, serde_json::to_vec_pretty(value)?)
651 .wrap_err_with(|| format!("failed to write {artifact} {}", path.display()))
652 }
653
654 /// Returns whether a workload needs Base Beryl enabled in its empty devnet.
655 pub fn requires_beryl(test_config: &TestConfig) -> bool {

Callers

nothing calls this directly

Calls 1

parentMethod · 0.45

Tested by

no test coverage detected