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

Function layout

atomic-core/src/pristine/span_patch_storage/legacy.rs:178–291  ·  view source on GitHub ↗
(
    context: &SpanRenderContext<'_, T>,
    inode: Inode,
    retain_content: bool,
)

Source from the content-addressed store, hash-verified

176}
177
178pub(super) fn layout<T: SpanPatchReadTxn>(
179 context: &SpanRenderContext<'_, T>,
180 inode: Inode,
181 retain_content: bool,
182) -> Result<Option<SpanRecordState>> {
183 let Some(graph) = context.txn.legacy_span_graph(inode, context.visible)? else {
184 return Ok(None);
185 };
186 let owner = context
187 .txn
188 .get_external(graph.position.change)?
189 .context("legacy file owner hash missing")?;
190 let creator = context
191 .changes
192 .get(&owner)
193 .context("legacy file creator outside closure")?;
194 let ordinal = creator
195 .legacy
196 .files
197 .iter()
198 .position(|pos| *pos == graph.position.pos.get())
199 .context("legacy inode has no canonical FileAdd")?;
200 let ordinal = u32::try_from(ordinal)?;
201 ensure!(
202 creator.span.is_none(),
203 "typed span root index is missing; cannot fall back to legacy graph"
204 );
205 let mut content = Vec::new();
206 let mut spans: Vec<VisibleSpan> = Vec::new();
207 let mut output_len = 0usize;
208 for node in graph.nodes {
209 let hash = context
210 .txn
211 .get_external(node.change)?
212 .context("legacy content owner hash missing")?;
213 let change = context
214 .changes
215 .get(&hash)
216 .context("legacy content outside closure")?;
217 let candidates: Vec<_> = change
218 .legacy
219 .ranges
220 .iter()
221 .filter(|(file_owner, pos, start, end)| {
222 *file_owner == owner
223 && *pos == graph.position.pos.get()
224 && *start <= node.start.get()
225 && node.end.get() <= *end
226 })
227 .collect();
228 ensure!(
229 candidates.len() == 1,
230 "legacy vertex has no unique immutable authored range"
231 );
232 let (_, _, start, end) = *candidates[0];
233 ensure!(
234 end <= change.contents.len() as u64,
235 "legacy declaration is outside verified content"

Callers 2

render_boundedMethod · 0.85
record_stateFunction · 0.85

Calls 10

getMethod · 0.65
legacy_span_graphMethod · 0.45
contextMethod · 0.45
get_externalMethod · 0.45
positionMethod · 0.45
iterMethod · 0.45
collectMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected