pub struct PackageDatabase { /* private fields */ }Expand description
On-disk package database
Implementations§
Source§impl PackageDatabase
impl PackageDatabase
pub fn new(db_path: &str) -> Self
Sourcepub fn load(&mut self) -> Result<(), KernelError>
pub fn load(&mut self) -> Result<(), KernelError>
Load database from VFS.
If the database file does not exist or the VFS is not available, the in-memory database remains empty – this is not an error.
Sourcepub fn save(&self) -> Result<(), KernelError>
pub fn save(&self) -> Result<(), KernelError>
Save database to VFS.
Creates parent directories if needed. Silently succeeds if the VFS is not available (early boot).
Sourcepub fn record_install(&mut self, record: DbPackageRecord)
pub fn record_install(&mut self, record: DbPackageRecord)
Record a package installation.
Sourcepub fn record_remove(&mut self, name: &str) -> Option<DbPackageRecord>
pub fn record_remove(&mut self, name: &str) -> Option<DbPackageRecord>
Record a package removal.
Returns the removed record so the caller can log or undo it.
Sourcepub fn query_installed(&self) -> Vec<&DbPackageRecord>
pub fn query_installed(&self) -> Vec<&DbPackageRecord>
Query all installed packages.
Sourcepub fn is_installed(&self, name: &str) -> bool
pub fn is_installed(&self, name: &str) -> bool
Check if a package is installed.
Sourcepub fn get(&self, name: &str) -> Option<&DbPackageRecord>
pub fn get(&self, name: &str) -> Option<&DbPackageRecord>
Get a package record by name.
Sourcepub fn track_config_file(&mut self, package: &str, config: ConfigRecord)
pub fn track_config_file(&mut self, package: &str, config: ConfigRecord)
Record a configuration file for a package.
Sourcepub fn is_config_modified(&self, package: &str, path: &str) -> bool
pub fn is_config_modified(&self, package: &str, path: &str) -> bool
Check whether a config file has been modified by the user.
Sourcepub fn list_config_files(&self, package: &str) -> &[ConfigRecord]
pub fn list_config_files(&self, package: &str) -> &[ConfigRecord]
List all tracked config files for a package.
Sourcepub fn find_orphans(&self) -> Vec<String>
pub fn find_orphans(&self) -> Vec<String>
Find orphan packages (packages with zero reverse dependencies).
A package is an orphan if no other installed package depends on it.