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

Method resolve_view_chain

atomic-core/src/pristine/traits/view.rs:323–346  ·  view source on GitHub ↗

Resolve the view chain for a draft view. Walks the `parent` links from the given view upward, collecting the IDs of each **Draft** ancestor. Stops when a **Shared ancestor (or the root) is reached. # Example ```ignore // feature-login (Draft, parent=service-auth) // service-auth (Draft, parent=dev) // dev (Shared, parent=main) let chain = txn.resolve_view_chain(&feature_login)?; //

(&self, view: &ViewState)

Source from the content-addressed store, hash-verified

321 /// // GRAPH is the implicit base (dev is Shared → stop)
322 /// ```
323 fn resolve_view_chain(&self, view: &ViewState) -> Result<Vec<u64>, PristineError> {
324 let mut chain: Vec<u64> = Vec::new();
325
326 if view.kind.is_shared() {
327 // Shared views read directly from GRAPH, no chain needed
328 return Ok(chain);
329 }
330
331 chain.push(view.id);
332
333 let mut cursor = view.parent;
334 while let Some(parent_id) = cursor {
335 let parent = self.get_view_by_id(parent_id)?;
336 match parent {
337 Some(p) if p.kind.is_draft() => {
338 chain.push(p.id);
339 cursor = p.parent;
340 }
341 _ => break, // Shared ancestor or not found → GRAPH is the base
342 }
343 }
344
345 Ok(chain)
346 }
347
348 /// Find all views that have the given view as their parent.
349 ///

Callers 1

Implementers 3

context.rsatomic-core/src/record/context.rs
read.rsatomic-core/src/pristine/txn/read.rs
view.rsatomic-core/src/pristine/txn/write/vie

Calls 4

is_sharedMethod · 0.80
is_draftMethod · 0.80
pushMethod · 0.45
get_view_by_idMethod · 0.45

Tested by

no test coverage detected