(local_key: u64, config: config::presentation::Config)
| 123 | ); |
| 124 | |
| 125 | fn load_impl(local_key: u64, config: config::presentation::Config) -> Result<graph::MainGraph> { |
| 126 | // register subgraph info |
| 127 | for cfg in &config.graphs { |
| 128 | let info = NodeInfo { |
| 129 | inputs: cfg.inputs.iter().map(|conn| conn.name.clone()).collect(), |
| 130 | outputs: cfg.outputs.iter().map(|conn| conn.name.clone()).collect(), |
| 131 | }; |
| 132 | graph::GraphSlice::registry_local().get(local_key).insert( |
| 133 | cfg.name.clone(), |
| 134 | graph::GraphSlice { |
| 135 | cons: Box::new(move |_, _| Err(anyhow!("graph is not loaded"))), |
| 136 | info, |
| 137 | }, |
| 138 | ); |
| 139 | } |
| 140 | let global_nodes_keys: Vec<_> = config |
| 141 | .nodes |
| 142 | .iter() |
| 143 | .map(|n| &n.entity.name) |
| 144 | .cloned() |
| 145 | .collect(); |
| 146 | |
| 147 | let config = config::translate_config(local_key, config)?; |
| 148 | config::graphviz::dump(&config)?; |
| 149 | |
| 150 | // update graph constructor |
| 151 | for cfg in &config.graphs { |
| 152 | let cfg = cfg.clone(); |
| 153 | let info = NodeInfo { |
| 154 | inputs: cfg.inputs.clone(), |
| 155 | outputs: cfg.outputs.clone(), |
| 156 | }; |
| 157 | graph::GraphSlice::registry_local().get(local_key).insert( |
| 158 | cfg.name.clone(), |
| 159 | graph::GraphSlice { |
| 160 | cons: Box::new(move |name, table| { |
| 161 | graph::Graph::load( |
| 162 | graph::context(name, cfg.name.clone(), local_key), |
| 163 | &cfg, |
| 164 | table, |
| 165 | ) |
| 166 | }), |
| 167 | info, |
| 168 | }, |
| 169 | ); |
| 170 | } |
| 171 | |
| 172 | // register shared nodes |
| 173 | let ctx = graph::context("__GLOBAL__".to_owned(), "__GLOBAL__".to_owned(), local_key); |
| 174 | let global_resources = |
| 175 | resource::UniqueResourceCollection::new(ctx.local_key, ctx.id, &config.resources) |
| 176 | .take_into_arc(); |
| 177 | for k in global_nodes_keys { |
| 178 | let cfg = config.nodes.get(&k).unwrap(); |
| 179 | node::SharedProxy::registry_local().get(local_key).insert( |
| 180 | cfg.entity.name.clone(), |
| 181 | node::load_shared(cfg, &config, ctx.clone(), global_resources.clone())?, |
| 182 | ); |
no test coverage detected