Skip to main content

concinnity_dev/authoring/
template_spec.rs

1// World-template bridging on top of the world spec bridge.
2//
3// The generic `AssetSpec` -> `serde_json::Value` conversion lives in
4// `concinnity_cook::authoring::spec` (a build-side crate, kept out of the shipped
5// runtime). This module re-exports those primitives so the app's public API
6// (`crate::spec_to_value`, ...) stays stable, and adds the
7// world-template convenience the authoring layer uses.
8
9use concinnity_cook::authoring::template::WorldTemplate;
10use serde_json::Value;
11
12pub use concinnity_cook::authoring::spec::{arg_value_to_json, spec_args, spec_to_value};
13
14/// A world template's assets as world-line entries, in application order.
15pub fn world_template_entries(t: &WorldTemplate) -> Vec<Value> {
16    t.assets().iter().map(spec_to_value).collect()
17}
18
19#[cfg(test)]
20mod tests {
21    use super::*;
22
23    #[test]
24    fn world_template_entries_yields_world_lines() {
25        let template = concinnity_cook::authoring::template::TEMPLATES
26            .first()
27            .expect("at least one template");
28        let entries = world_template_entries(template);
29        assert!(!entries.is_empty());
30        for entry in &entries {
31            assert!(entry.get("name").is_some());
32            assert!(entry.get("type").is_some());
33            assert!(entry.get("args").is_some());
34        }
35    }
36}