pub struct Package<'a> { /* private fields */ }
Expand description
A single unique libapt package.
Implementations§
Source§impl<'a> Package<'a>
impl<'a> Package<'a>
pub fn new(cache: &'a Cache, ptr: UniquePtr<PkgIterator>) -> Package<'a>
Sourcepub fn rdepends(&self) -> &HashMap<DepType, Vec<Dependency<'a>>>
pub fn rdepends(&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.
For example where we use the crate::DepType::Depends
key:
use rust_apt::{new_cache, DepType};
let cache = new_cache!().unwrap();
let pkg = cache.get("apt").unwrap();
for dep in pkg.rdepends().get(&DepType::Depends).unwrap() {
if dep.is_or() {
for base_dep in dep.iter() {
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 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.
Sourcepub fn inst_state(&self) -> PkgInstState
pub fn inst_state(&self) -> PkgInstState
The installed state of this package.
Sourcepub fn selected_state(&self) -> PkgSelectedState
pub fn selected_state(&self) -> PkgSelectedState
The selected state of this package.
Sourcepub fn current_state(&self) -> PkgCurrentState
pub fn current_state(&self) -> PkgCurrentState
The current state of this package.
Sourcepub fn installed(&self) -> Option<Version<'a>>
pub fn installed(&self) -> Option<Version<'a>>
Returns the version object of the installed version.
If there isn’t an installed version, returns None
Sourcepub fn candidate(&self) -> Option<Version<'a>>
pub fn candidate(&self) -> Option<Version<'a>>
Returns the version object of the candidate.
If there isn’t a candidate, returns None
Sourcepub fn install_version(&self) -> Option<Version<'a>>
pub fn install_version(&self) -> Option<Version<'a>>
Returns the install version if it exists.
§This differs from crate::Package::installed
in the
§following ways:
- If a version is marked for install this will return the version to be installed.
- If an installed package is marked for removal, this will return
None
.
Sourcepub fn versions(&self) -> impl Iterator<Item = Version<'a>>
pub fn versions(&self) -> impl Iterator<Item = Version<'a>>
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 = PkgIterator>§
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 is_essential(&self) -> bool
pub fn is_essential(&self) -> bool
True if the package is essential.
Sourcepub unsafe fn current_version(&self) -> UniquePtr<VerIterator>
pub unsafe fn current_version(&self) -> UniquePtr<VerIterator>
Get a pointer the the currently installed version.
§Safety
If the inner pointer is null segfaults can occur.
Using crate::raw::IntoRawIter::make_safe
to convert to an Option
is recommended.
The returned UniquePtr cannot outlive the cache.
Sourcepub unsafe fn versions(&self) -> UniquePtr<VerIterator>
pub unsafe fn versions(&self) -> UniquePtr<VerIterator>
Get a pointer to the beginning of the VerIterator.
§Safety
If the inner pointer is null segfaults can occur.
Using crate::raw::IntoRawIter::make_safe
to convert to an Option
is recommended.
The returned UniquePtr cannot outlive the cache.
Sourcepub unsafe fn provides(&self) -> UniquePtr<PrvIterator>
pub unsafe fn provides(&self) -> UniquePtr<PrvIterator>
Get the providers of this package.
§Safety
If the inner pointer is null segfaults can occur.
Using crate::raw::IntoRawIter::make_safe
to convert to an Option
is recommended.
The returned UniquePtr cannot outlive the cache.
Sourcepub unsafe fn rdepends(&self) -> UniquePtr<DepIterator>
pub unsafe fn rdepends(&self) -> UniquePtr<DepIterator>
Get the reverse dependencies of this package
§Safety
If the inner pointer is null segfaults can occur.
Using crate::raw::IntoRawIter::make_safe
to convert to an Option
is recommended.
The returned UniquePtr cannot outlive the cache.
pub fn index(&self) -> u64
Sourcepub unsafe fn unique(&self) -> UniquePtr<PkgIterator>
pub unsafe fn unique(&self) -> UniquePtr<PkgIterator>
Clone the pointer.
§Safety
If the inner pointer is null segfaults can occur.
Using crate::raw::IntoRawIter::make_safe
to convert to an Option
is recommended.
The returned UniquePtr cannot outlive the cache.