vasari_core/schema/
mod.rs1mod action;
2mod attribution;
3mod constraint;
4mod intent;
5mod plan;
6
7pub use action::{Action, PlanRef};
8pub use attribution::{Attribution, AttributionTarget, Evidence, EvidenceKind};
9pub use constraint::{Constraint, ConstraintPolarity};
10pub use intent::Intent;
11pub use plan::{Plan, PlanStep};
12
13use serde::{Deserialize, Serialize};
14
15#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
17pub struct NodeId(pub String);
18
19impl NodeId {
20 pub fn as_str(&self) -> &str {
21 &self.0
22 }
23}
24
25impl std::fmt::Display for NodeId {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 write!(f, "{}", self.0)
28 }
29}
30
31#[derive(Debug, Serialize, Deserialize)]
33#[serde(tag = "type", rename_all = "snake_case")]
34pub enum Node {
35 Intent(Intent),
36 Plan(Plan),
37 Constraint(Constraint),
38 Action(Action),
39 Attribution(Attribution),
40}
41
42impl Node {
43 pub fn id(&self) -> &NodeId {
44 match self {
45 Node::Intent(n) => &n.id,
46 Node::Plan(n) => &n.id,
47 Node::Constraint(n) => &n.id,
48 Node::Action(n) => &n.id,
49 Node::Attribution(n) => &n.id,
50 }
51 }
52}