Skip to main content

greentic_flow/
ir.rs

1/// Classification of a node's component type.
2#[derive(Debug, Clone, PartialEq, Eq)]
3pub enum NodeKind {
4    /// A node backed by an adapter operation in the form `<namespace>.<adapter>.<operation>`.
5    Adapter {
6        namespace: String,
7        adapter: String,
8        operation: String,
9    },
10    /// Any other node type that does not match the adapter convention.
11    Builtin(String),
12}
13
14/// Classify a component string into [`NodeKind`].
15pub fn classify_node_type(node_type: &str) -> NodeKind {
16    let parts = node_type.split('.').collect::<Vec<_>>();
17    if parts.len() >= 3 {
18        let namespace = parts[0].to_string();
19        let adapter = parts[1].to_string();
20        let operation = parts[2..].join(".");
21        NodeKind::Adapter {
22            namespace,
23            adapter,
24            operation,
25        }
26    } else {
27        NodeKind::Builtin(node_type.to_string())
28    }
29}