Skip to main content

jellyflow_runtime/schema/migration/
canonicalize.rs

1use jellyflow_core::core::{NodeId, NodeKindKey};
2use jellyflow_core::ops::GraphTransaction;
3
4#[derive(Debug, Clone)]
5pub struct NodeKindRewrite {
6    pub node: NodeId,
7    pub from: NodeKindKey,
8    pub to: NodeKindKey,
9}
10
11impl NodeKindRewrite {
12    pub fn node(&self) -> NodeId {
13        self.node
14    }
15
16    pub fn from(&self) -> &NodeKindKey {
17        &self.from
18    }
19
20    pub fn to(&self) -> &NodeKindKey {
21        &self.to
22    }
23}
24
25#[derive(Debug, Clone)]
26pub struct CanonicalizeKindsPlan {
27    pub tx: GraphTransaction,
28    pub rewrites: Vec<NodeKindRewrite>,
29}
30
31impl CanonicalizeKindsPlan {
32    pub(in crate::schema) fn from_parts(
33        tx: GraphTransaction,
34        rewrites: Vec<NodeKindRewrite>,
35    ) -> Self {
36        Self { tx, rewrites }
37    }
38
39    pub fn transaction(&self) -> &GraphTransaction {
40        &self.tx
41    }
42
43    pub fn rewrites(&self) -> &[NodeKindRewrite] {
44        &self.rewrites
45    }
46
47    pub fn into_parts(self) -> (GraphTransaction, Vec<NodeKindRewrite>) {
48        (self.tx, self.rewrites)
49    }
50}