Promotes a graph to the main one in this context. # Arguments `graph` - graph # Returns This context # Example ``` # use ciphercore_base::graphs::create_context; # use ciphercore_base::data_types::{array_type, INT32}; let c = create_context().unwrap(); let g = c.create_graph().unwrap(); let t = array_type(vec![3, 2], INT32); let n = g.input(t).unwrap(); n.set_as_output().unwrap(); g.finalize
(&self, graph: Graph)
| 3988 | /// c.set_main_graph(g).unwrap(); |
| 3989 | /// ``` |
| 3990 | pub fn set_main_graph(&self, graph: Graph) -> Result<Context> { |
| 3991 | let current_main_graph = self.body.borrow().main_graph.clone(); |
| 3992 | match current_main_graph { |
| 3993 | Some(_) => Err(runtime_error!("Main graph is already set")), |
| 3994 | None => { |
| 3995 | if graph.get_context() != *self { |
| 3996 | return Err(runtime_error!("Main graph is from the wrong context")); |
| 3997 | } |
| 3998 | graph.check_finalized()?; |
| 3999 | self.body.borrow_mut().main_graph = Some(graph.downgrade()); |
| 4000 | Ok(self.clone()) |
| 4001 | } |
| 4002 | } |
| 4003 | } |
| 4004 | |
| 4005 | /// Returns the vector of graphs contained in this context in order of creation. |
| 4006 | /// |