pub struct PackageManager { /* private fields */ }Expand description
Package manager
Implementations§
Source§impl PackageManager
impl PackageManager
pub fn new() -> Self
Sourcepub fn signature_policy(&self) -> &SignaturePolicy
pub fn signature_policy(&self) -> &SignaturePolicy
Get a reference to the current signature policy.
Sourcepub fn set_signature_policy(&mut self, policy: SignaturePolicy)
pub fn set_signature_policy(&mut self, policy: SignaturePolicy)
Replace the signature policy.
Sourcepub fn trusted_keys_mut(&mut self) -> &mut TrustedKeyRing
pub fn trusted_keys_mut(&mut self) -> &mut TrustedKeyRing
Get a mutable reference to the trusted key ring.
Sourcepub fn add_repository(&mut self, repo: Repository)
pub fn add_repository(&mut self, repo: Repository)
Add a repository
Sourcepub fn install(&mut self, name: String, version_req: String) -> PkgResult<()>
pub fn install(&mut self, name: String, version_req: String) -> PkgResult<()>
Install a package by name and version.
Uses the default SignaturePolicy – signatures are required and
force_unsigned is false.
Sourcepub fn install_with_options(
&mut self,
name: String,
version_req: String,
options: InstallOptions,
) -> PkgResult<()>
pub fn install_with_options( &mut self, name: String, version_req: String, options: InstallOptions, ) -> PkgResult<()>
Install a package with explicit install options.
When options.force_unsigned is true, a failed signature verification
produces a warning instead of a hard error. A hash mismatch (if
expected_hash is provided) always fails regardless.
Sourcepub fn remove_preserving_configs(
&mut self,
package_id: &PackageId,
) -> PkgResult<()>
pub fn remove_preserving_configs( &mut self, package_id: &PackageId, ) -> PkgResult<()>
Remove a package, preserving user-modified config files.
Config files that the user has edited are saved with a .bak suffix
instead of being deleted.
Sourcepub fn remove_orphans(&mut self) -> PkgResult<Vec<PackageId>>
pub fn remove_orphans(&mut self) -> PkgResult<Vec<PackageId>>
Find and remove orphan packages (packages with no reverse dependencies).
Returns the list of removed package names.
Sourcepub fn list_installed(&self) -> Vec<(PackageId, Version)>
pub fn list_installed(&self) -> Vec<(PackageId, Version)>
List installed packages
Sourcepub fn is_installed(&self, package_id: &PackageId) -> bool
pub fn is_installed(&self, package_id: &PackageId) -> bool
Check if package is installed
Sourcepub fn get_metadata(&self, package_id: &PackageId) -> Option<&PackageMetadata>
pub fn get_metadata(&self, package_id: &PackageId) -> Option<&PackageMetadata>
Get installed package metadata
Sourcepub fn begin_transaction(&mut self) -> PkgResult<()>
pub fn begin_transaction(&mut self) -> PkgResult<()>
Begin an atomic transaction.
All install/remove operations after this call are staged and only
applied when commit_transaction() is called. If any operation
fails or rollback_transaction() is called, the package state
reverts to the snapshot taken here.
Sourcepub fn commit_transaction(&mut self) -> PkgResult<()>
pub fn commit_transaction(&mut self) -> PkgResult<()>
Commit the current transaction, persisting state to the database.
Sourcepub fn rollback_transaction(&mut self) -> PkgResult<()>
pub fn rollback_transaction(&mut self) -> PkgResult<()>
Roll back the current transaction, restoring the pre-transaction state.
Sourcepub fn upgrade(&mut self, package_id: &str) -> PkgResult<()>
pub fn upgrade(&mut self, package_id: &str) -> PkgResult<()>
Upgrade a single installed package to the latest available version.
Sourcepub fn upgrade_all(&mut self) -> PkgResult<usize>
pub fn upgrade_all(&mut self) -> PkgResult<usize>
Upgrade all installed packages to their latest available versions.
Sourcepub fn search(&self, query: &str) -> Vec<(PackageId, Version)>
pub fn search(&self, query: &str) -> Vec<(PackageId, Version)>
Search available packages by name substring.
Sourcepub fn get_package_info(&self, package_id: &str) -> Option<PackageMetadata>
pub fn get_package_info(&self, package_id: &str) -> Option<PackageMetadata>
Get detailed information about a package (installed or available).
Sourcepub fn file_manifest(&self) -> &FileManifest
pub fn file_manifest(&self) -> &FileManifest
Get a reference to the file manifest.
Sourcepub fn file_manifest_mut(&mut self) -> &mut FileManifest
pub fn file_manifest_mut(&mut self) -> &mut FileManifest
Get a mutable reference to the file manifest.
Sourcepub fn database(&self) -> &PackageDatabase
pub fn database(&self) -> &PackageDatabase
Get a reference to the persistent database.
Sourcepub fn database_mut(&mut self) -> &mut PackageDatabase
pub fn database_mut(&mut self) -> &mut PackageDatabase
Get a mutable reference to the persistent database.