jellyflow_core/ops/fragment/
model.rs1use std::collections::BTreeMap;
2
3use serde::{Deserialize, Serialize};
4
5use crate::core::{
6 Binding, BindingId, Edge, EdgeId, GraphId, GraphImport, Group, GroupId, Node, NodeId, Port,
7 PortId, StickyNote, StickyNoteId, Symbol, SymbolId,
8};
9
10pub const GRAPH_FRAGMENT_VERSION: u32 = 1;
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct GraphFragment {
16 pub version: u32,
17 pub nodes: BTreeMap<NodeId, Node>,
18 pub ports: BTreeMap<PortId, Port>,
19 pub edges: BTreeMap<EdgeId, Edge>,
20 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
21 pub imports: BTreeMap<GraphId, GraphImport>,
22 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
23 pub groups: BTreeMap<GroupId, Group>,
24 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
25 pub sticky_notes: BTreeMap<StickyNoteId, StickyNote>,
26 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
27 pub symbols: BTreeMap<SymbolId, Symbol>,
28 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
29 pub bindings: BTreeMap<BindingId, Binding>,
30}
31
32impl Default for GraphFragment {
33 fn default() -> Self {
34 Self {
35 version: GRAPH_FRAGMENT_VERSION,
36 nodes: BTreeMap::new(),
37 ports: BTreeMap::new(),
38 edges: BTreeMap::new(),
39 imports: BTreeMap::new(),
40 groups: BTreeMap::new(),
41 sticky_notes: BTreeMap::new(),
42 symbols: BTreeMap::new(),
43 bindings: BTreeMap::new(),
44 }
45 }
46}