MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / retrieve_content_bounded

Function retrieve_content_bounded

atomic-repository/src/repository/content.rs:1654–1690  ·  view source on GitHub ↗

The query consumer's cap applies to emitted bytes, not to raw change sizes. Both paths use the ordinary graph visibility and semantic rendering rules.

(
    txn: &T,
    changes: &C,
    inode: Inode,
    position: Position<NodeId>,
    options: atomic_core::output::alive::RetrieveOptions,
    max_bytes: usize,
)

Source from the content-addressed store, hash-verified

1652/// The query consumer's cap applies to emitted bytes, not to raw change sizes.
1653/// Both paths use the ordinary graph visibility and semantic rendering rules.
1654pub(crate) fn retrieve_content_bounded<T, C>(
1655 txn: &T,
1656 changes: &C,
1657 inode: Inode,
1658 position: Position<NodeId>,
1659 options: atomic_core::output::alive::RetrieveOptions,
1660 max_bytes: usize,
1661) -> atomic_core::record::RecordResult<BoundedContent>
1662where
1663 T: atomic_core::pristine::GraphTxnT
1664 + atomic_core::pristine::InodeGraphOps<InodeError = atomic_core::pristine::PristineError>
1665 + atomic_core::pristine::TreeTxnT,
1666 C: atomic_core::change::ChangeStore,
1667{
1668 if let Some(content) =
1669 try_retrieve_linear_content_bounded(txn, changes, inode, position, &options, max_bytes)?
1670 {
1671 return Ok(content);
1672 }
1673 let result = match atomic_core::pristine::InodeScopedGraph::new(txn, inode) {
1674 Ok(scoped) => atomic_core::output::repo::output_file_to_buffer_bounded(
1675 &scoped, changes, position, options, max_bytes,
1676 ),
1677 Err(_) => atomic_core::output::repo::output_file_to_buffer_bounded(
1678 txn, changes, position, options, max_bytes,
1679 ),
1680 }
1681 .map_err(|error| {
1682 atomic_core::record::RecordError::Io(std::io::Error::other(error.to_string()))
1683 })?;
1684 Ok(match result.content {
1685 Some(bytes) => BoundedContent::Complete(bytes),
1686 None => BoundedContent::Oversized {
1687 retained_bytes: result.buffer_high_water,
1688 },
1689 })
1690}
1691
1692fn try_retrieve_linear_content_bounded<T, C>(
1693 txn: &T,