Skip to main content

vizij_graph_core/
lib.rs

1//! Vizij's node graph on Arora's behavior tree.
2//!
3//! This crate defines the graph format ([`types`]), the editor registry
4//! ([`schema`]) and topology helpers ([`topo`]); the functions of the graph
5//! format's own module, `@vizij/graph` ([`vizij_functions`]); the importer
6//! from a graph to a behavior tree ([`import`]); and
7//! [`TreeRuntime`](tree_runtime::TreeRuntime), which runs a graph on the
8//! tree. A graph's nodes are calls of `arora-dataflow-nodes`' functions, whose
9//! modules this crate re-exports.
10
11pub use arora_dataflow_nodes::{functions, kind, params, ports, select, task, vocab};
12
13pub mod eval;
14pub mod import;
15pub mod schema;
16pub mod topo;
17pub mod tree_runtime;
18pub mod types;
19pub mod vizij_functions;
20
21#[cfg(test)]
22mod fixtures;
23#[cfg(test)]
24mod tree_tests;
25
26pub use eval::{Context, NodeFunction, NodeFunctionRegistry, NodeFunctions, PortValue};
27pub use schema::registry;
28pub use topo::topo_order;
29pub use types::*;
30
31#[cfg(test)]
32mod vocabulary_tests {
33    use vizij_api_core::value as vizij;
34
35    use crate::vocab;
36
37    /// Vizij's value vocabulary and the node vocabulary declare records and
38    /// enumerations under the same ids, so a value built by either reads in
39    /// both.
40    #[test]
41    fn records_and_enumerations_have_the_same_ids_in_both_vocabularies() {
42        assert_eq!(vocab::RECORD_TYPE, vizij::RECORD_TYPE);
43        assert_eq!(vocab::ENUM_TYPE, vizij::ENUM_TYPE);
44        assert_eq!(
45            vocab::record([("x", vocab::float(1.0))]),
46            vizij::record([("x", vizij::float(1.0))])
47        );
48        assert_eq!(
49            vocab::enumeration("on", vocab::float(1.0)),
50            vizij::enumeration("on", vizij::float(1.0))
51        );
52    }
53}