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

Method add_node_annotation

ciphercore-base/src/graphs.rs:4489–4515  ·  view source on GitHub ↗
(
        &self,
        node: &Node,
        annotation: NodeAnnotation,
    )

Source from the content-addressed store, hash-verified

4487 }
4488
4489 pub(super) fn add_node_annotation(
4490 &self,
4491 node: &Node,
4492 annotation: NodeAnnotation,
4493 ) -> Result<Context> {
4494 if node.get_graph().get_context() != *self {
4495 return Err(runtime_error!(
4496 "The node to be annotated is in a different context"
4497 ));
4498 }
4499 if self.is_finalized() {
4500 return Err(runtime_error!(
4501 "Can't add a node annotation in a finalized context"
4502 ));
4503 }
4504 let node_id = node.get_id();
4505 let graph_id = node.get_graph().get_id();
4506 let key = (graph_id, node_id);
4507 let mut cell = self.body.borrow_mut();
4508 let annotations = cell.nodes_annotations.get_mut(&key);
4509 if let Some(annotation_vec) = annotations {
4510 annotation_vec.push(annotation);
4511 } else {
4512 cell.nodes_annotations.insert(key, vec![annotation]);
4513 }
4514 Ok(self.clone())
4515 }
4516
4517 pub(super) fn get_node_annotations(&self, node: Node) -> Result<Vec<NodeAnnotation>> {
4518 if node.get_graph().get_context() != *self {

Callers 4

instantiateMethod · 0.80
add_annotationMethod · 0.80
context_generatorsFunction · 0.80

Calls 7

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

Tested by

no test coverage detected