Wrap `inner` so structural lookups are attempted in `inode` first.
(inner: &'a T, inode: Inode)
| 45 | { |
| 46 | /// Wrap `inner` so structural lookups are attempted in `inode` first. |
| 47 | pub fn new(inner: &'a T, inode: Inode) -> Result<Self, PristineError> { |
| 48 | let scoped = inner.inode_graph_is_populated(inode)?; |
| 49 | let mut adjacency: std::collections::HashMap<GraphNode<NodeId>, Vec<SerializedGraphEdge>> = |
| 50 | std::collections::HashMap::new(); |
| 51 | let mut vertices: Vec<GraphNode<NodeId>> = Vec::new(); |
| 52 | if scoped { |
| 53 | let iter = inner.iter_inode_vertices(inode)?; |
| 54 | for entry in iter { |
| 55 | let (node, edge) = entry?; |
| 56 | if !adjacency.contains_key(&node) { |
| 57 | vertices.push(node); |
| 58 | } |
| 59 | adjacency.entry(node).or_default().push(edge); |
| 60 | } |
| 61 | vertices.sort_by(|left, right| { |
| 62 | (left.change.get(), left.start.get(), left.end.get()).cmp(&( |
| 63 | right.change.get(), |
| 64 | right.start.get(), |
| 65 | right.end.get(), |
| 66 | )) |
| 67 | }); |
| 68 | vertices.dedup(); |
| 69 | } |
| 70 | Ok(Self { |
| 71 | inner, |
| 72 | inode, |
| 73 | scoped, |
| 74 | adjacency, |
| 75 | vertices, |
| 76 | }) |
| 77 | } |
| 78 | |
| 79 | /// Whether the inode index is populated (and therefore scoping active). |
| 80 | pub fn is_scoped(&self) -> bool { |
nothing calls this directly
no test coverage detected