pub struct ObjectStore { /* private fields */ }Expand description
Git-like content-addressed object store at <repo>/.vasari/.
Layout:
objects/<sha[0..2]>/<sha[2..]> canonical JSON nodes, gzip-compressed
index/targets/
Implementations§
Source§impl ObjectStore
impl ObjectStore
Sourcepub const FORMAT_VERSION: &'static str = "2"
pub const FORMAT_VERSION: &'static str = "2"
On-disk store format generation. Bumped when a change to node identity
or layout makes older stores unreadable. v2 introduced per-turn Intents
and the WholeFile attribution target — both change node hashes, so a
pre-v2 store no longer resolves and must be re-ingested.
Sourcepub fn open(repo_root: &Path) -> Result<Self, VasariError>
pub fn open(repo_root: &Path) -> Result<Self, VasariError>
Open (or initialize) the store at <repo_root>/.vasari/.
A fresh store is stamped with [FORMAT_VERSION]. An existing store whose
stamp differs (or is missing, i.e. pre-v2) is refused with
VasariError::IncompatibleStore — re-ingest is the migration path.
Sourcepub fn put(&self, node: &Node) -> Result<NodeId, VasariError>
pub fn put(&self, node: &Node) -> Result<NodeId, VasariError>
Write a node to the object store. Idempotent: re-writing the same ID is a no-op.
Sourcepub fn get(&self, id: &NodeId) -> Result<Option<Node>, VasariError>
pub fn get(&self, id: &NodeId) -> Result<Option<Node>, VasariError>
Read a node by ID. Returns None if not present.
Sourcepub fn lookup_attributions(
&self,
path: &str,
line: u32,
) -> Result<Vec<NodeId>, VasariError>
pub fn lookup_attributions( &self, path: &str, line: u32, ) -> Result<Vec<NodeId>, VasariError>
Look up attribution node IDs for a specific file:line target.
The index is rebuilt by vasari fsck if stale.
Sourcepub fn iter_all(&self) -> Result<Vec<Node>, VasariError>
pub fn iter_all(&self) -> Result<Vec<Node>, VasariError>
Iterate all nodes in the object store. Used by vasari sessions and vasari files.
Walks the objects/ directory; no ordering guarantee.
Sourcepub fn resolve_prefix(&self, prefix: &str) -> Result<NodeId, VasariError>
pub fn resolve_prefix(&self, prefix: &str) -> Result<NodeId, VasariError>
Resolve a (possibly abbreviated) node-id prefix to a full NodeId.
Matches against object FILENAMES under objects/<shard>/ — never
deserializes a node, never panics. Returns:
• Ok(id) on a unique match
• Err(InvalidNodeId) for non-hex / too-short input
• Err(NodeNotFound) when nothing matches
• Err(AmbiguousPrefix { count }) when 2+ nodes share the prefix
Minimum length is 4 (2-char shard + 2-char body) to avoid matching an
entire shard. The on-disk layout is objects/<sha[0..2]>/<sha[2..]>,
so the shard is the lookup directory and the remainder is a filename
prefix — an O(files-in-shard) scan, not an O(all-nodes) deserialize.
Sourcepub fn rebuild_index(&self) -> Result<usize, VasariError>
pub fn rebuild_index(&self) -> Result<usize, VasariError>
Rebuild all indexes from the object store. Called by vasari fsck.