Read a vault path from KG node metadata. New identity schemes can change node IDs without changing this retrieval contract.
(node: &KgNode)
| 651 | /// Read a vault path from KG node metadata. New identity schemes can change |
| 652 | /// node IDs without changing this retrieval contract. |
| 653 | fn memory_path_from_node(node: &KgNode) -> Option<String> { |
| 654 | node.metadata |
| 655 | .as_ref() |
| 656 | .and_then(|metadata| metadata.get("vault_path")) |
| 657 | .and_then(|path| path.as_str()) |
| 658 | .filter(|path| path.starts_with("memory/") && path.ends_with(".md")) |
| 659 | .map(String::from) |
| 660 | .or_else(|| memory_node_id_to_path(&node.id)) |
| 661 | } |
| 662 | |
| 663 | fn memory_node_id_to_path(node_id: &str) -> Option<String> { |
| 664 | let (_, name) = iri::parse_memory(node_id).ok()?; |
no test coverage detected