qualia_core_db/poet_host/invoke/manifold/
axes.rs1use super::super::args;
4use crate::container_10d::axis_role::{AxisRole, AXIS_ORDER, COORDINATE_AXES, SELECTOR_AXES};
5use vibe::{Diagnostic, Span, Value};
6
7pub fn taxonomy(_args: &Value, _span: Span) -> Result<Value, Diagnostic> {
9 let roles: Vec<Value> = AXIS_ORDER
10 .iter()
11 .enumerate()
12 .map(|(i, name)| {
13 let role = if COORDINATE_AXES.contains(&i) {
14 if i == crate::container_10d::axis_role::MU_AXIS {
15 AxisRole::CoordinateCarrier
16 } else {
17 AxisRole::Coordinate
18 }
19 } else if SELECTOR_AXES.contains(&i) {
20 AxisRole::Selector
21 } else {
22 AxisRole::Undefined
23 };
24 args::record([
25 ("axis", Value::String((*name).into())),
26 ("index", Value::U64(i as u64)),
27 ("role", Value::String(format!("{role:?}"))),
28 ("in_distance", Value::Bool(role.is_coordinate())),
29 ])
30 })
31 .collect();
32 Ok(Value::List(roles))
33}
34
35#[cfg(test)]
36mod tests {
37 use super::*;
38
39 #[test]
40 fn ten_axes() {
41 match taxonomy(&Value::Null, Span { start: 0, end: 0 }).unwrap() {
42 Value::List(xs) => assert_eq!(xs.len(), 10),
43 other => panic!("{other:?}"),
44 }
45 }
46}