(
&self,
inode: Inode,
segments: Option<&mut Vec<VisibleSpan>>,
max_bytes: usize,
)
| 1290 | } |
| 1291 | |
| 1292 | fn render_internal( |
| 1293 | &self, |
| 1294 | inode: Inode, |
| 1295 | segments: Option<&mut Vec<VisibleSpan>>, |
| 1296 | max_bytes: usize, |
| 1297 | ) -> Result<(Vec<u8>, bool)> { |
| 1298 | let root = self.txn.span_root(inode)?.context("span root missing")?; |
| 1299 | let root_id = NodeId::new(root[0]); |
| 1300 | ensure!(self.visible.contains(root_id), "span root outside view"); |
| 1301 | let root_hash = self |
| 1302 | .txn |
| 1303 | .get_external(root_id)? |
| 1304 | .context("root hash missing")?; |
| 1305 | let root_change = self |
| 1306 | .changes |
| 1307 | .get(&root_hash) |
| 1308 | .context("root change outside closure")?; |
| 1309 | let patch = root_change |
| 1310 | .span |
| 1311 | .as_ref() |
| 1312 | .context("root typed span section missing")?; |
| 1313 | let mut roots = 0; |
| 1314 | for op in &patch.ops { |
| 1315 | if let SpanOp::Root { |
| 1316 | ordinal, |
| 1317 | start, |
| 1318 | end, |
| 1319 | .. |
| 1320 | } = op |
| 1321 | { |
| 1322 | if *start == root[1] |
| 1323 | && *end == root[2] |
| 1324 | && self.txn.span_file_inode(&ExternalFile { |
| 1325 | owner: root_hash, |
| 1326 | ordinal: *ordinal, |
| 1327 | })? == Some(inode) |
| 1328 | { |
| 1329 | roots += 1; |
| 1330 | } |
| 1331 | } |
| 1332 | } |
| 1333 | ensure!(roots == 1, "root index differs from hashed change"); |
| 1334 | let observed: BTreeSet<_> = self |
| 1335 | .txn |
| 1336 | .span_edits_for_inode(inode)? |
| 1337 | .into_iter() |
| 1338 | .filter(|(_, row)| { |
| 1339 | self.visible |
| 1340 | .contains(NodeId::new(decode_words::<5>(row)[2])) |
| 1341 | }) |
| 1342 | .collect(); |
| 1343 | ensure!( |
| 1344 | observed == self.expected.get(&inode.get()).cloned().unwrap_or_default(), |
| 1345 | "visible span index differs from hashed changes" |
| 1346 | ); |
| 1347 | let mut out = RenderOutput { |
| 1348 | bytes: Vec::new(), |
| 1349 | limit: max_bytes, |
no test coverage detected