pub fn flatten_schema(schema: &Schema) -> (Vec<SchemaNode>, u32)Expand description
Flatten a schema to (nodes, root).
Post-order: every child is pushed before its parent, so an index is never handed out for a slot still being built. No dedup — a schema crosses once per option per load, and hashing every subtree to save a few nodes on a cold path is the wrong trade.
The root is therefore always the last node: root == nodes.len() - 1.
§Examples
use lattice_plugin_sdk::shape::{Schema, SchemaNode, ScalarKind, flatten_schema};
let (nodes, root) = flatten_schema(&Schema::list(Schema::int()));
assert_eq!(nodes, vec![SchemaNode::Scalar(ScalarKind::Int), SchemaNode::List(0)]);
assert_eq!(root, 1);