(
&self,
node: &Node,
annotation: NodeAnnotation,
)
| 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 { |
no test coverage detected