MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / load_spec

Function load_spec

tools/bloom-reference/src/main.rs:77–85  ·  view source on GitHub ↗

Load and parse the JSON spec. Relative paths in the spec (`scene`, `env.path`) are resolved against the spec file's own directory so the spec can live alongside its assets and be moved as a unit.

(path: &Path)

Source from the content-addressed store, hash-verified

75/// directory so the spec can live alongside its assets and be moved
76/// as a unit.
77fn load_spec(path: &Path) -> Result<(ViewSpec, PathBuf), String> {
78 let text = std::fs::read_to_string(path).map_err(|e| format!("read {:?}: {e}", path))?;
79 let spec: ViewSpec = serde_json::from_str(&text).map_err(|e| format!("parse {:?}: {e}", path))?;
80 let base_dir = path
81 .parent()
82 .map(|p| p.to_path_buf())
83 .unwrap_or_else(|| PathBuf::from("."));
84 Ok((spec, base_dir))
85}
86
87// ============================================================
88// Scene representation

Callers 1

parse_argsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected