MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / recover_original_context

Method recover_original_context

ciphercore-base/src/graphs.rs:3792–3862  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

3790 }
3791
3792 fn recover_original_context(&self) -> Result<Context> {
3793 let result_context = create_context()?;
3794 for graph in &self.graphs {
3795 let _result_graph =
3796 Self::recover_original_graph(graph.clone(), result_context.clone())?;
3797 }
3798 if let Some(id) = self.main_graph {
3799 let rebuilt_main_graph = {
3800 let current_graphs = &result_context.body.borrow().graphs;
3801 if id >= current_graphs.len() as u64 {
3802 return Err(runtime_error!("Non-existent main graph"));
3803 }
3804 current_graphs[id as usize].clone()
3805 };
3806 result_context.set_main_graph(rebuilt_main_graph)?;
3807 }
3808 for (id, _) in &self.graphs_names {
3809 let current_graphs = &result_context.body.borrow().graphs;
3810 if *id >= current_graphs.len() as u64 {
3811 return Err(runtime_error!("graphs_names contain an invalid ID"));
3812 }
3813 }
3814 for ((graph_id, node_id), _) in &self.nodes_names {
3815 let current_graphs = &result_context.body.borrow().graphs;
3816 if *graph_id >= current_graphs.len() as u64 {
3817 return Err(runtime_error!("nodes_names contain an invalid graph ID"));
3818 }
3819 let current_nodes = &current_graphs[*graph_id as usize].body.borrow().nodes;
3820 if *node_id >= current_nodes.len() as u64 {
3821 return Err(runtime_error!("nodes_names contain an invalid node ID"));
3822 }
3823 }
3824 for (id, name) in &self.graphs_names {
3825 let current_graph = {
3826 let current_graphs = &result_context.body.borrow().graphs;
3827 current_graphs[*id as usize].clone()
3828 };
3829 result_context.set_graph_name(current_graph, name)?;
3830 }
3831 for ((graph_id, node_id), name) in &self.nodes_names {
3832 let current_node = {
3833 let current_graphs = &result_context.body.borrow().graphs;
3834 let current_nodes = &current_graphs[*graph_id as usize].body.borrow().nodes;
3835 current_nodes[*node_id as usize].clone()
3836 };
3837 result_context.set_node_name(current_node, name)?;
3838 }
3839 for (id, annotations) in &self.graphs_annotations {
3840 let current_graph = {
3841 let current_graphs = &result_context.body.borrow().graphs;
3842 current_graphs[*id as usize].clone()
3843 };
3844 for annotation in annotations {
3845 result_context.add_graph_annotation(&current_graph, annotation.clone())?;
3846 }
3847 }
3848 for ((graph_id, node_id), annotations) in &self.nodes_annotations {
3849 let current_node = {

Callers 1

deserializeMethod · 0.80

Calls 8

cloneMethod · 0.80
add_graph_annotationMethod · 0.80
add_node_annotationMethod · 0.80
create_contextFunction · 0.70
set_main_graphMethod · 0.45
set_graph_nameMethod · 0.45
set_node_nameMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected