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

Method view_manifest

atomic-repository/src/repository/views.rs:633–682  ·  view source on GitHub ↗

Export a view's complete identity as a [`ViewManifest`]. The manifest carries the view's change log **exactly as stored** in `VIEW_CHANGES` (for a draft this includes the inherited prefix copied at fork time), plus scope, parent name, and the view's merkle state. The exported manifest is verified before it is returned, so a corrupted log surfaces here rather than on the receiving end.

(&self, name: &str)

Source from the content-addressed store, hash-verified

631 /// The exported manifest is verified before it is returned, so a
632 /// corrupted log surfaces here rather than on the receiving end.
633 pub fn view_manifest(&self, name: &str) -> Result<ViewManifest, RepositoryError> {
634 let txn = self
635 .pristine
636 .read_txn()
637 .map_err(|e| RepositoryError::Database(e.to_string()))?;
638
639 let view = txn
640 .get_view(name)
641 .map_err(|e| RepositoryError::Database(e.to_string()))?
642 .ok_or_else(|| RepositoryError::ViewNotFound {
643 name: name.to_string(),
644 })?;
645
646 let parent = match view.parent {
647 Some(parent_id) => txn
648 .get_view_by_id(parent_id)
649 .map_err(|e| RepositoryError::Database(e.to_string()))?
650 .map(|p| p.name),
651 None => None,
652 };
653
654 let mut changes = Vec::with_capacity(view.change_count as usize);
655 for item in txn
656 .iter_changes(&view, 0)
657 .map_err(|e| RepositoryError::Database(e.to_string()))?
658 {
659 let (_seq, node_id, _merkle) =
660 item.map_err(|e| RepositoryError::Database(e.to_string()))?;
661 let hash = txn
662 .get_external(node_id)
663 .map_err(|e| RepositoryError::Database(e.to_string()))?
664 .ok_or_else(|| {
665 RepositoryError::Database(format!(
666 "change {} in view '{}' has no external hash",
667 node_id.0, name
668 ))
669 })?;
670 changes.push(hash);
671 }
672
673 let manifest = ViewManifest {
674 name: view.name.clone(),
675 scope: view.kind,
676 parent,
677 changes,
678 state: view.state,
679 };
680 manifest.verify()?;
681 Ok(manifest)
682 }
683
684 /// Declaratively apply a [`ViewManifest`]: create the view with its
685 /// declared identity if absent, then fast-forward its change log to

Calls 8

read_txnMethod · 0.80
get_viewMethod · 0.45
get_view_by_idMethod · 0.45
iter_changesMethod · 0.45
get_externalMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
verifyMethod · 0.45