pub struct InstalledComponentRegistry { /* private fields */ }Expand description
The persisted registry of installed components.
Implementations§
Source§impl InstalledComponentRegistry
impl InstalledComponentRegistry
Sourcepub fn load() -> Self
pub fn load() -> Self
Load the registry from disk, returning an empty one if absent or unreadable (never panics — a corrupt registry degrades to empty).
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Persist the registry to disk atomically, creating ~/.mlstack/ first.
Writes to installed.json.tmp in the same directory, then fs::renames
it into place. rename is atomic on the same filesystem, so an
interrupted write (crash, disk full, power loss) can never leave a
corrupt installed.json that would make load() return empty and risk
clobbering a sealed core component (Tenet 2).
Sourcepub fn reload_and_save() -> Result<()>
pub fn reload_and_save() -> Result<()>
Load then save — normalizes the file on disk (used after manual edits).
Sourcepub fn mark_installed(&mut self, component: InstalledComponent)
pub fn mark_installed(&mut self, component: InstalledComponent)
Record (or update) a component. If sealed is requested on a component
that is already sealed, the seal is preserved (never accidentally
unsealed via re-mark without explicit Self::unseal).
Sourcepub fn seal_core(
&mut self,
id: &str,
version: Option<String>,
source_index: Option<String>,
location: Option<String>,
pip_packages: Vec<String>,
installed_at: Option<String>,
)
pub fn seal_core( &mut self, id: &str, version: Option<String>, source_index: Option<String>, location: Option<String>, pip_packages: Vec<String>, installed_at: Option<String>, )
Convenience: mark a core component as installed + sealed.
Sourcepub fn get(&self, id: &str) -> Option<&InstalledComponent>
pub fn get(&self, id: &str) -> Option<&InstalledComponent>
Lookup a component by id.
Sourcepub fn is_installed(&self, id: &str) -> bool
pub fn is_installed(&self, id: &str) -> bool
Is a component with this id recorded as installed?
Sourcepub fn installed_ids(&self) -> HashSet<String>
pub fn installed_ids(&self) -> HashSet<String>
All recorded component ids.
Sourcepub fn all_pip_packages(&self) -> Vec<String>
pub fn all_pip_packages(&self) -> Vec<String>
Every pip package name owned by any recorded component (for uninstall).
Sourcepub fn unseal(&mut self, id: &str) -> bool
pub fn unseal(&mut self, id: &str) -> bool
Explicitly unseal a core component (only via deliberate user action,
e.g. --unseal-core). Returns true if it was sealed and is now not.
Sourcepub fn remove(&mut self, id: &str) -> bool
pub fn remove(&mut self, id: &str) -> bool
Remove a component record (does not uninstall — see Stage 6).
Sourcepub fn iter(&self) -> impl Iterator<Item = &InstalledComponent>
pub fn iter(&self) -> impl Iterator<Item = &InstalledComponent>
Iterate over recorded components.
Trait Implementations§
Source§impl Clone for InstalledComponentRegistry
impl Clone for InstalledComponentRegistry
Source§fn clone(&self) -> InstalledComponentRegistry
fn clone(&self) -> InstalledComponentRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InstalledComponentRegistry
impl Debug for InstalledComponentRegistry
Source§impl Default for InstalledComponentRegistry
impl Default for InstalledComponentRegistry
Source§fn default() -> InstalledComponentRegistry
fn default() -> InstalledComponentRegistry
Source§impl<'de> Deserialize<'de> for InstalledComponentRegistry
impl<'de> Deserialize<'de> for InstalledComponentRegistry
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>,
Auto Trait Implementations§
impl Freeze for InstalledComponentRegistry
impl RefUnwindSafe for InstalledComponentRegistry
impl Send for InstalledComponentRegistry
impl Sync for InstalledComponentRegistry
impl Unpin for InstalledComponentRegistry
impl UnsafeUnpin for InstalledComponentRegistry
impl UnwindSafe for InstalledComponentRegistry
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
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more