Resolve an inode position to an actual Inode value. Given a position referencing a file's inode span, looks up the actual Inode value from the position→inode mapping. # Arguments `txn` - Transaction for lookups `inode_pos` - Position of the inode span `current_change` - NodeId of the change being applied # Returns `Ok(Some(inode))` - The resolved inode `Ok(None)` - Position is ROOT or inode n
(
txn: &T,
inode_pos: &Position<Option<Hash>>,
current_change: NodeId,
)
| 165 | /// ROOT positions don't have an associated inode, so this returns `None` |
| 166 | /// for those cases. |
| 167 | pub fn resolve_inode<T: GraphTxnT + TreeTxnT>( |
| 168 | txn: &T, |
| 169 | inode_pos: &Position<Option<Hash>>, |
| 170 | current_change: NodeId, |
| 171 | ) -> Result<Option<Inode>, LocalApplyError> { |
| 172 | let internal_pos = resolve_position(txn, inode_pos, current_change)?; |
| 173 | |
| 174 | // ROOT positions don't have an associated inode |
| 175 | if internal_pos.change.is_root() { |
| 176 | return Ok(None); |
| 177 | } |
| 178 | |
| 179 | // Look up the Inode from the position |
| 180 | txn.position_inode(internal_pos) |
| 181 | .map_err(|e| LocalApplyError::Internal { |
| 182 | message: format!("Failed to resolve inode: {}", e), |
| 183 | }) |
| 184 | } |
| 185 | |
| 186 | /// Resolve the `introduced_by` field of an edge. |
| 187 | /// |
no test coverage detected