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

Method resolve_view_chain

atomic-core/src/pristine/traits/view.rs:375–398  ·  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

373 /// // GRAPH is the implicit base (dev is Shared → stop)
374 /// ```
375 fn resolve_view_chain(&self, view: &ViewState) -> Result<Vec<u64>, PristineError> {
376 let mut chain: Vec<u64> = Vec::new();
377
378 if view.kind.is_shared() {
379 // Shared views read directly from GRAPH, no chain needed
380 return Ok(chain);
381 }
382
383 chain.push(view.id);
384
385 let mut cursor = view.parent;
386 while let Some(parent_id) = cursor {
387 let parent = self.get_view_by_id(parent_id)?;
388 match parent {
389 Some(p) if p.kind.is_draft() => {
390 chain.push(p.id);
391 cursor = p.parent;
392 }
393 _ => break, // Shared ancestor or not found → GRAPH is the base
394 }
395 }
396
397 Ok(chain)
398 }
399
400 /// Find all views that have the given view as their parent.
401 ///

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
pushMethod · 0.45
get_view_by_idMethod · 0.45
is_draftMethod · 0.45

Tested by

no test coverage detected