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

Function output_file_to_buffer_bounded

atomic-core/src/output/repo/file.rs:1016–1058  ·  view source on GitHub ↗

Render into a bounded consumer buffer using the ordinary semantic renderer. A missing content buffer means rendered output exceeded `max_bytes`; it is never a partial file. Graph traversal and semantic-merge scratch are separate from this consumer bound. Complete output matches the ordinary unbounded renderer, including its conflict markers and semantic-merge resolution. # Examples ```no_run us

(
    txn: &T,
    changes: &C,
    position: Position<NodeId>,
    retrieve_options: RetrieveOptions,
    max_bytes: usize,
)

Source from the content-addressed store, hash-verified

1014/// Propagates graph, content-store, and renderer failures. Only the buffer's own
1015/// limit rejection is classified as oversized content.
1016pub fn output_file_to_buffer_bounded<T: GraphTxnT, C: ChangeStore>(
1017 txn: &T,
1018 changes: &C,
1019 position: Position<NodeId>,
1020 retrieve_options: RetrieveOptions,
1021 max_bytes: usize,
1022) -> Result<BoundedFileOutput, OutputError> {
1023 let retrieved = retrieve_graph(txn, position, retrieve_options)
1024 .map_err(|error| OutputError::Pristine(Box::new(error)))?;
1025 let mut graph = retrieved.graph;
1026 let order = compute_order(&mut graph);
1027 let resolved = resolve_conflicts_semantically(txn, changes, &graph, &order)?;
1028 let had_fork = !resolved.is_empty();
1029 let mut output = BoundedOutput {
1030 writer: Writer::new(BoundedBytes {
1031 bytes: Vec::new(),
1032 max_bytes,
1033 exceeded: false,
1034 }),
1035 };
1036 let result = output_graph_content_resolved(
1037 changes,
1038 |id| txn.get_external(id),
1039 &graph,
1040 &order,
1041 &mut output,
1042 &resolved,
1043 );
1044 if output.writer.inner().exceeded {
1045 return Ok(BoundedFileOutput {
1046 content: None,
1047 had_fork_structure: had_fork,
1048 buffer_high_water: output.writer.inner().bytes.len(),
1049 });
1050 }
1051 result?;
1052 let bytes = output.writer.into_inner().bytes;
1053 Ok(BoundedFileOutput {
1054 buffer_high_water: bytes.len(),
1055 content: Some(bytes),
1056 had_fork_structure: had_fork,
1057 })
1058}
1059
1060/// Bounded rendered bytes and consumer-buffer measurements, excluding renderer scratch.
1061#[derive(Debug, Clone, PartialEq, Eq)]

Calls 10

retrieve_graphFunction · 0.85
PristineClass · 0.85
compute_orderFunction · 0.85
is_emptyMethod · 0.45
get_externalMethod · 0.45
innerMethod · 0.45
lenMethod · 0.45
into_innerMethod · 0.45