Struct rust_apt::package::Package

source ·
pub struct Package<'a> { /* private fields */ }

Implementations§

source§

impl<'a> Package<'a>

source

pub fn new(cache: &'a Cache, ptr: RawPackage) -> Package<'a>

source

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())
   }
}
source

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");
source

pub fn installed(&self) -> Option<Version<'_>>

Returns the version object of the installed version.

If there isn’t an installed version, returns None

source

pub fn candidate(&self) -> Option<Version<'_>>

Returns the version object of the candidate.

If there isn’t a candidate, returns None

source

pub fn versions(&self) -> impl Iterator<Item = Version<'_>>

Returns a version list starting with the newest and ending with the oldest.

source

pub fn provides(&self) -> impl Iterator<Item = Provider<'a>>

Returns a list of providers

source

pub fn is_upgradable(&self) -> bool

Check if the package is upgradable.

§skip_depcache:

Skipping the DepCache is unnecessary if it’s already been initialized. If you’re unsure use false

  • true = Increases performance by skipping the pkgDepCache.
  • false = Use DepCache to check if the package is upgradable
source

pub fn is_auto_installed(&self) -> bool

Check if the package is auto installed. (Not installed by the user)

source

pub fn is_auto_removable(&self) -> bool

Check if the package is auto removable

source

pub fn is_now_broken(&self) -> bool

Check if the package is now broken

source

pub fn is_inst_broken(&self) -> bool

Check if the package package installed is broken

source

pub fn marked_install(&self) -> bool

Check if the package is marked install

source

pub fn marked_upgrade(&self) -> bool

Check if the package is marked upgrade

source

pub fn marked_purge(&self) -> bool

Check if the package is marked purge

source

pub fn marked_delete(&self) -> bool

Check if the package is marked delete

source

pub fn marked_keep(&self) -> bool

Check if the package is marked keep

source

pub fn marked_downgrade(&self) -> bool

Check if the package is marked downgrade

source

pub fn marked_reinstall(&self) -> bool

Check if the package is marked reinstall

source

pub fn mark_auto(&self, mark_auto: bool) -> bool

§Mark a package as automatically installed.
§mark_auto:
  • true = Mark the package as automatically installed.
  • false = Mark the package as manually installed.
source

pub fn mark_keep(&self) -> bool

§Mark a package for keep.
§Returns:
  • true if the mark was successful
  • false if the mark was unsuccessful

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.

source

pub fn mark_delete(&self, purge: bool) -> bool

§Mark a package for removal.
§Returns:
  • true if the mark was successful
  • false if the mark was unsuccessful
§purge:
  • true = Configuration files will be removed along with the package.
  • false = Only the package will be removed.
source

pub fn mark_install(&self, auto_inst: bool, from_user: bool) -> bool

§Mark a package for installation.
§auto_inst:
  • true = Additionally mark the dependencies for this package.
  • false = Mark only this package.
§from_user:
  • true = The package will be marked manually installed.
  • false = The package will be unmarked automatically installed.
§Returns:
  • true if the mark was successful
  • false if the mark was unsuccessful

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

source

pub fn mark_reinstall(&self, reinstall: bool) -> bool

§Mark a package for reinstallation.
§Returns:
  • true if the mark was successful
  • false if the mark was unsuccessful
§reinstall:
  • true = The package will be marked for reinstall.
  • false = The package will be unmarked for reinstall.
source

pub fn protect(&self)

Protect a package’s state for when crate::cache::Cache::resolve is called.

Methods from Deref<Target = RawPackage>§

source

pub fn name(&self) -> &str

Get the name of the package without the architecture.

source

pub fn arch(&self) -> &str

Get the architecture of a package.

source

pub fn fullname(&self, pretty: bool) -> String

Get the fullname of the package.

Pretty is a bool that will omit the native arch.

source

pub fn id(&self) -> u32

Get the ID of a package.

source

pub fn current_state(&self) -> u8

Get the current state of a package.

source

pub fn inst_state(&self) -> u8

Get the installed state of a package.

source

pub fn selected_state(&self) -> u8

Get the selected state of a package.

source

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.

source

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.

source

pub fn unsafe_provides(&self) -> Provider

Get the providers of this package

source

pub fn unsafe_rev_depends(&self) -> Dependency

source

pub fn is_essential(&self) -> bool

True if the package is essential.

source

pub fn raw_next(&self)

source

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++

source

pub fn unique(&self) -> Package

source

pub fn current_version(&self) -> Option<RawVersion>

source

pub fn version_list(&self) -> Option<RawVersion>

source

pub fn provides_list(&self) -> Option<RawProvider>

source

pub fn rev_depends_list(&self) -> Option<RawDependency>

source

pub fn is_installed(&self) -> bool

True if the Package is installed.

source

pub fn has_versions(&self) -> bool

True if the package has versions.

If a package has no versions it is considered virtual.

source

pub fn has_provides(&self) -> bool

True if the package provides any other packages.

Trait Implementations§

source§

impl<'a> Deref for Package<'a>

§

type Target = Package

The resulting type after dereferencing.
source§

fn deref(&self) -> &RawPackage

Dereferences the value.
source§

impl<'a> Hash for Package<'a>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a> PartialEq for Package<'a>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> Eq for Package<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Package<'a>

§

impl<'a> !Send for Package<'a>

§

impl<'a> !Sync for Package<'a>

§

impl<'a> Unpin for Package<'a>

§

impl<'a> !UnwindSafe for Package<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.