(
&self,
inode: Inode,
segments: Option<&mut Vec<VisibleSpan>>,
max_bytes: usize,
)
| 1546 | } |
| 1547 | |
| 1548 | fn render_internal( |
| 1549 | &self, |
| 1550 | inode: Inode, |
| 1551 | segments: Option<&mut Vec<VisibleSpan>>, |
| 1552 | max_bytes: usize, |
| 1553 | ) -> Result<(Vec<u8>, bool)> { |
| 1554 | let root = self.txn.span_root(inode)?.context("span root missing")?; |
| 1555 | let root_id = NodeId::new(root[0]); |
| 1556 | ensure!(self.visible.contains(root_id), "span root outside view"); |
| 1557 | let root_hash = self |
| 1558 | .txn |
| 1559 | .get_external(root_id)? |
| 1560 | .context("root hash missing")?; |
| 1561 | let root_change = self |
| 1562 | .changes |
| 1563 | .get(&root_hash) |
| 1564 | .context("root change outside closure")?; |
| 1565 | let patch = root_change |
| 1566 | .span |
| 1567 | .as_ref() |
| 1568 | .context("root typed span section missing")?; |
| 1569 | let mut roots = 0; |
| 1570 | for op in &patch.ops { |
| 1571 | if let SpanOp::Root { |
| 1572 | ordinal, |
| 1573 | start, |
| 1574 | end, |
| 1575 | .. |
| 1576 | } = op |
| 1577 | { |
| 1578 | if *start == root[1] |
| 1579 | && *end == root[2] |
| 1580 | && self.txn.span_file_inode(&ExternalFile { |
| 1581 | owner: root_hash, |
| 1582 | ordinal: *ordinal, |
| 1583 | })? == Some(inode) |
| 1584 | { |
| 1585 | roots += 1; |
| 1586 | } |
| 1587 | } |
| 1588 | } |
| 1589 | ensure!(roots == 1, "root index differs from hashed change"); |
| 1590 | let observed: BTreeSet<_> = self |
| 1591 | .txn |
| 1592 | .span_edits_for_inode(inode)? |
| 1593 | .into_iter() |
| 1594 | .filter(|(_, row)| { |
| 1595 | self.visible |
| 1596 | .contains(NodeId::new(decode_words::<5>(row)[2])) |
| 1597 | }) |
| 1598 | .collect(); |
| 1599 | ensure!( |
| 1600 | observed == self.expected.get(&inode.get()).cloned().unwrap_or_default(), |
| 1601 | "visible span index differs from hashed changes" |
| 1602 | ); |
| 1603 | let mut out = RenderOutput { |
| 1604 | bytes: Vec::new(), |
| 1605 | limit: max_bytes, |
no test coverage detected