pub struct SlotRegistry {
pub version: u32,
pub slots: Vec<SlotRecord>,
}Expand description
Root JSON object of slots.json.
Fields§
§version: u32§slots: Vec<SlotRecord>Implementations§
Source§impl SlotRegistry
impl SlotRegistry
pub const CURRENT_VERSION: u32 = 1
pub const CREATION_GRACE_PERIOD: Duration
Sourcepub fn load_or_empty(path: &Path) -> Result<Self, RegistryError>
pub fn load_or_empty(path: &Path) -> Result<Self, RegistryError>
Loads registry from path, or returns an empty registry if the file does not exist.
Sourcepub fn save_atomic(&self, path: &Path) -> Result<(), RegistryError>
pub fn save_atomic(&self, path: &Path) -> Result<(), RegistryError>
Saves the registry atomically to disk using a temporary file and rename.
Sourcepub fn find_by_id(&self, id: u32) -> Option<&SlotRecord>
pub fn find_by_id(&self, id: u32) -> Option<&SlotRecord>
Finds a slot by ID.
Sourcepub fn find_by_name(&self, name: &str) -> Option<&SlotRecord>
pub fn find_by_name(&self, name: &str) -> Option<&SlotRecord>
Finds a slot by leaf name.
Sourcepub fn occupied_ids(&self) -> Vec<u32>
pub fn occupied_ids(&self) -> Vec<u32>
Returns all currently occupied Slot IDs.
Sourcepub fn remove_by_name(&mut self, name: &str) -> bool
pub fn remove_by_name(&mut self, name: &str) -> bool
Removes a slot by leaf name, returning true if removed.
Sourcepub fn remove_by_id(&mut self, id: u32) -> bool
pub fn remove_by_id(&mut self, id: u32) -> bool
Removes a slot by ID, returning true if removed.
Sourcepub fn auto_gc(
&mut self,
registry_path: &Path,
repo_root: Option<&Path>,
respect_grace_period: bool,
) -> Result<usize, RegistryError>
pub fn auto_gc( &mut self, registry_path: &Path, repo_root: Option<&Path>, respect_grace_period: bool, ) -> Result<usize, RegistryError>
Auto-GC: inspects recorded worktrees, removes entries whose directory does not exist on disk (ignoring records within the grace period), saves the registry atomically, and invokes git worktree prune.
Trait Implementations§
Source§impl Clone for SlotRegistry
impl Clone for SlotRegistry
Source§impl Debug for SlotRegistry
impl Debug for SlotRegistry
Source§impl<'de> Deserialize<'de> for SlotRegistry
impl<'de> Deserialize<'de> for SlotRegistry
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
impl Eq for SlotRegistry
Source§impl PartialEq for SlotRegistry
impl PartialEq for SlotRegistry
Source§impl Serialize for SlotRegistry
impl Serialize for SlotRegistry
impl StructuralPartialEq for SlotRegistry
Auto Trait Implementations§
impl Freeze for SlotRegistry
impl RefUnwindSafe for SlotRegistry
impl Send for SlotRegistry
impl Sync for SlotRegistry
impl Unpin for SlotRegistry
impl UnsafeUnpin for SlotRegistry
impl UnwindSafe for SlotRegistry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.