pub struct Package<'a> { /* private fields */ }Implementations§
source§impl<'a> Package<'a>
impl<'a> Package<'a>
pub fn new(cache: &'a Cache, ptr: RawPackage) -> Package<'a>
sourcepub fn rdepends_map(&self) -> &HashMap<DepType, Vec<Dependency<'a>>>
pub fn rdepends_map(&self) -> &HashMap<DepType, Vec<Dependency<'a>>>
Returns a Reverse Dependency Map of the package
Dependencies are in a Vec<Dependency>
The Dependency struct represents an Or Group of dependencies.
The base deps are located in Dependency.base_deps
For example where we use the DepType::Depends key:
use rust_apt::new_cache;
use rust_apt::package::DepType;
let cache = new_cache!().unwrap();
let pkg = cache.get("apt").unwrap();
for dep in pkg.rdepends_map().get(&DepType::Depends).unwrap() {
if dep.is_or() {
for base_dep in &dep.base_deps {
println!("{}", base_dep.name())
}
} else {
// is_or is false so there is only one BaseDep
println!("{}", dep.first().name())
}
}sourcepub fn get_version(&'a self, version_str: &str) -> Option<Version<'a>>
pub fn get_version(&'a self, version_str: &str) -> Option<Version<'a>>
Return either a Version or None
§Example:
use rust_apt::new_cache;
let cache = new_cache!().unwrap();
let pkg = cache.get("apt").unwrap();
pkg.get_version("2.4.7");sourcepub fn installed(&self) -> Option<Version<'_>>
pub fn installed(&self) -> Option<Version<'_>>
Returns the version object of the installed version.
If there isn’t an installed version, returns None
sourcepub fn candidate(&self) -> Option<Version<'_>>
pub fn candidate(&self) -> Option<Version<'_>>
Returns the version object of the candidate.
If there isn’t a candidate, returns None
sourcepub fn versions(&self) -> impl Iterator<Item = Version<'_>>
pub fn versions(&self) -> impl Iterator<Item = Version<'_>>
Returns a version list starting with the newest and ending with the oldest.
sourcepub fn is_upgradable(&self) -> bool
pub fn is_upgradable(&self) -> bool
sourcepub fn is_auto_installed(&self) -> bool
pub fn is_auto_installed(&self) -> bool
Check if the package is auto installed. (Not installed by the user)
sourcepub fn is_auto_removable(&self) -> bool
pub fn is_auto_removable(&self) -> bool
Check if the package is auto removable
sourcepub fn is_now_broken(&self) -> bool
pub fn is_now_broken(&self) -> bool
Check if the package is now broken
sourcepub fn is_inst_broken(&self) -> bool
pub fn is_inst_broken(&self) -> bool
Check if the package package installed is broken
sourcepub fn marked_install(&self) -> bool
pub fn marked_install(&self) -> bool
Check if the package is marked install
sourcepub fn marked_upgrade(&self) -> bool
pub fn marked_upgrade(&self) -> bool
Check if the package is marked upgrade
sourcepub fn marked_purge(&self) -> bool
pub fn marked_purge(&self) -> bool
Check if the package is marked purge
sourcepub fn marked_delete(&self) -> bool
pub fn marked_delete(&self) -> bool
Check if the package is marked delete
sourcepub fn marked_keep(&self) -> bool
pub fn marked_keep(&self) -> bool
Check if the package is marked keep
sourcepub fn marked_downgrade(&self) -> bool
pub fn marked_downgrade(&self) -> bool
Check if the package is marked downgrade
sourcepub fn marked_reinstall(&self) -> bool
pub fn marked_reinstall(&self) -> bool
Check if the package is marked reinstall
sourcepub fn mark_keep(&self) -> bool
pub fn mark_keep(&self) -> bool
§Mark a package for keep.
§Returns:
This means that the package will not be changed from its current version. This will not stop a reinstall, but will stop removal, upgrades and downgrades
We don’t believe that there is any reason to unmark packages for keep. If someone has a reason, and would like it implemented, please put in a feature request.
sourcepub fn mark_delete(&self, purge: bool) -> bool
pub fn mark_delete(&self, purge: bool) -> bool
sourcepub fn mark_install(&self, auto_inst: bool, from_user: bool) -> bool
pub fn mark_install(&self, auto_inst: bool, from_user: bool) -> bool
§Mark a package for installation.
§auto_inst:
§from_user:
- true = The package will be marked manually installed.
- false = The package will be unmarked automatically installed.
§Returns:
If a package is already installed, at the latest version,
and you mark that package for install you will get true,
but the package will not be altered.
pkg.marked_install() will be false
sourcepub fn mark_reinstall(&self, reinstall: bool) -> bool
pub fn mark_reinstall(&self, reinstall: bool) -> bool
sourcepub fn protect(&self)
pub fn protect(&self)
Protect a package’s state
for when crate::cache::Cache::resolve is called.
Methods from Deref<Target = RawPackage>§
sourcepub fn fullname(&self, pretty: bool) -> String
pub fn fullname(&self, pretty: bool) -> String
Get the fullname of the package.
Pretty is a bool that will omit the native arch.
sourcepub fn current_state(&self) -> u8
pub fn current_state(&self) -> u8
Get the current state of a package.
sourcepub fn inst_state(&self) -> u8
pub fn inst_state(&self) -> u8
Get the installed state of a package.
sourcepub fn selected_state(&self) -> u8
pub fn selected_state(&self) -> u8
Get the selected state of a package.
sourcepub fn unsafe_current_version(&self) -> Version
pub fn unsafe_current_version(&self) -> Version
Get a pointer the the currently installed version
Safety: If Version.end() is true, calling methods on the Version can segfault.
sourcepub fn unsafe_version_list(&self) -> Version
pub fn unsafe_version_list(&self) -> Version
Get a pointer to the beginning of the VerIterator
Safety: If Version.end() is true, calling methods on the Version can segfault.
sourcepub fn unsafe_provides(&self) -> Provider
pub fn unsafe_provides(&self) -> Provider
Get the providers of this package
pub fn unsafe_rev_depends(&self) -> Dependency
sourcepub fn is_essential(&self) -> bool
pub fn is_essential(&self) -> bool
True if the package is essential.
pub fn raw_next(&self)
sourcepub fn end(&self) -> bool
pub fn end(&self) -> bool
This will tell you if the inner PkgIterator is null
The cxx is_null function will still show non null because of wrappers in c++
pub fn unique(&self) -> Package
pub fn current_version(&self) -> Option<RawVersion>
pub fn version_list(&self) -> Option<RawVersion>
pub fn provides_list(&self) -> Option<RawProvider>
pub fn rev_depends_list(&self) -> Option<RawDependency>
sourcepub fn is_installed(&self) -> bool
pub fn is_installed(&self) -> bool
True if the Package is installed.
sourcepub fn has_versions(&self) -> bool
pub fn has_versions(&self) -> bool
True if the package has versions.
If a package has no versions it is considered virtual.
sourcepub fn has_provides(&self) -> bool
pub fn has_provides(&self) -> bool
True if the package provides any other packages.