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

Method add_graph_annotation

ciphercore-base/src/graphs.rs:4531–4551  ·  view source on GitHub ↗
(&self, graph: &Graph, annotation: GraphAnnotation)

Source from the content-addressed store, hash-verified

4529 }
4530
4531 fn add_graph_annotation(&self, graph: &Graph, annotation: GraphAnnotation) -> Result<Context> {
4532 if graph.get_context() != *self {
4533 return Err(runtime_error!(
4534 "The graph to be annotated is in a different context"
4535 ));
4536 }
4537 if self.is_finalized() {
4538 return Err(runtime_error!(
4539 "Can't set a graph annotation in a finalized context"
4540 ));
4541 }
4542 let id = graph.get_id();
4543 let mut cell = self.body.borrow_mut();
4544 let annotations = cell.graphs_annotations.get_mut(&id);
4545 if let Some(annotation_vec) = annotations {
4546 annotation_vec.push(annotation);
4547 } else {
4548 cell.graphs_annotations.insert(id, vec![annotation]);
4549 }
4550 Ok(self.clone())
4551 }
4552
4553 fn get_graph_annotations(&self, graph: Graph) -> Result<Vec<GraphAnnotation>> {
4554 if graph.get_context() != *self {

Callers 3

add_annotationMethod · 0.80
context_generatorsFunction · 0.80

Calls 6

is_finalizedMethod · 0.80
cloneMethod · 0.80
get_contextMethod · 0.45
get_idMethod · 0.45
pushMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected