Skip to main content

ObjectStore

Struct ObjectStore 

Source
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//- → attribution node IDs (newline-separated) refs/ human-readable refs HEAD current intent context

Implementations§

Source§

impl ObjectStore

Source

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.

Source

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.

Source

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.

Source

pub fn get(&self, id: &NodeId) -> Result<Option<Node>, VasariError>

Read a node by ID. Returns None if not present.

Source

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.

Source

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.

Source

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.

Source

pub fn rebuild_index(&self) -> Result<usize, VasariError>

Rebuild all indexes from the object store. Called by vasari fsck.

Trait Implementations§

Source§

impl Debug for ObjectStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.