pub struct ProjectRegistry {
pub entries: HashMap<String, RegistryEntry>,
}Expand description
In-memory representation of the global project registry.
Fields§
§entries: HashMap<String, RegistryEntry>Entries keyed by the WorktreeId::key.
Implementations§
Source§impl ProjectRegistry
impl ProjectRegistry
Sourcepub fn load(layout: &StorageLayout) -> Result<Self, StorageError>
pub fn load(layout: &StorageLayout) -> Result<Self, StorageError>
Load the registry from StorageLayout::global_registry().
Returns an empty registry if the file does not exist.
§Errors
Returns StorageError if the file exists but cannot be parsed.
Sourcepub fn save(&self, layout: &StorageLayout) -> Result<(), StorageError>
pub fn save(&self, layout: &StorageLayout) -> Result<(), StorageError>
Persist the registry to StorageLayout::global_registry().
§Errors
Returns StorageError if the parent directory cannot be created or
the file cannot be written.
Sourcepub fn upsert(&mut self, worktree: &WorktreeId, root_path: &Path)
pub fn upsert(&mut self, worktree: &WorktreeId, root_path: &Path)
Register or update an entry for the given worktree.
Sourcepub fn touch(&mut self, worktree: &WorktreeId)
pub fn touch(&mut self, worktree: &WorktreeId)
Update the last-access timestamp for a worktree (if registered).
Sourcepub fn remove(&mut self, worktree: &WorktreeId)
pub fn remove(&mut self, worktree: &WorktreeId)
Remove a worktree from the registry.
Sourcepub fn add_tag(&mut self, worktree: &WorktreeId, tag: impl Into<String>)
pub fn add_tag(&mut self, worktree: &WorktreeId, tag: impl Into<String>)
Add a tag to an existing entry.
Sourcepub fn get(&self, worktree: &WorktreeId) -> Option<&RegistryEntry>
pub fn get(&self, worktree: &WorktreeId) -> Option<&RegistryEntry>
Look up an entry by worktree key.
Sourcepub fn list_recent(&self) -> Vec<&RegistryEntry>
pub fn list_recent(&self) -> Vec<&RegistryEntry>
Return all entries, sorted by last_accessed_at descending.
Trait Implementations§
Source§impl Clone for ProjectRegistry
impl Clone for ProjectRegistry
Source§fn clone(&self) -> ProjectRegistry
fn clone(&self) -> ProjectRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ProjectRegistry
impl Debug for ProjectRegistry
Source§impl Default for ProjectRegistry
impl Default for ProjectRegistry
Source§fn default() -> ProjectRegistry
fn default() -> ProjectRegistry
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ProjectRegistry
impl<'de> Deserialize<'de> for ProjectRegistry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ProjectRegistry
impl RefUnwindSafe for ProjectRegistry
impl Send for ProjectRegistry
impl Sync for ProjectRegistry
impl Unpin for ProjectRegistry
impl UnsafeUnpin for ProjectRegistry
impl UnwindSafe for ProjectRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more