Obtain byte-to-span mappings under this exact view closure.
(&self, inode: Inode)
| 1200 | |
| 1201 | /// Obtain byte-to-span mappings under this exact view closure. |
| 1202 | pub fn record_state(&self, inode: Inode) -> Result<Option<SpanRecordState>> { |
| 1203 | let Some(root) = self.txn.span_root(inode)? else { |
| 1204 | return Ok(None); |
| 1205 | }; |
| 1206 | if !self.visible.contains(NodeId::new(root[0])) { |
| 1207 | return Ok(None); |
| 1208 | } |
| 1209 | let mut spans = Vec::new(); |
| 1210 | let (content, oversized) = self.render_internal(inode, Some(&mut spans), usize::MAX)?; |
| 1211 | ensure!(!oversized, "span render exceeds addressable memory"); |
| 1212 | let owner = self |
| 1213 | .txn |
| 1214 | .get_external(NodeId::new(root[0]))? |
| 1215 | .context("root hash missing")?; |
| 1216 | let change = self |
| 1217 | .changes |
| 1218 | .get(&owner) |
| 1219 | .context("root change outside closure")?; |
| 1220 | let patch = change |
| 1221 | .span |
| 1222 | .as_ref() |
| 1223 | .context("root typed span section missing")?; |
| 1224 | let mut found = None; |
| 1225 | for op in &patch.ops { |
| 1226 | if let SpanOp::Root { |
| 1227 | ordinal, |
| 1228 | start, |
| 1229 | end, |
| 1230 | .. |
| 1231 | } = op |
| 1232 | { |
| 1233 | let file = ExternalFile { |
| 1234 | owner, |
| 1235 | ordinal: *ordinal, |
| 1236 | }; |
| 1237 | if *start == root[1] |
| 1238 | && *end == root[2] |
| 1239 | && self.txn.span_file_inode(&file)? == Some(inode) |
| 1240 | { |
| 1241 | ensure!(found.is_none(), "ambiguous span root"); |
| 1242 | found = Some(file); |
| 1243 | } |
| 1244 | } |
| 1245 | } |
| 1246 | let file = found.context("root index differs from hashed change")?; |
| 1247 | let mut dependencies = BTreeSet::new(); |
| 1248 | dependencies.insert(owner); |
| 1249 | if let Some(edits) = self.expected.get(&inode.get()) { |
| 1250 | for (_, row) in edits { |
| 1251 | let author = NodeId::new(decode_words::<5>(row)[2]); |
| 1252 | dependencies.insert( |
| 1253 | self.txn |
| 1254 | .get_external(author)? |
| 1255 | .context("span edit author missing")?, |
| 1256 | ); |
| 1257 | } |
| 1258 | } |
| 1259 | Ok(Some(SpanRecordState { |