Struct Package

Source
pub struct Package<'a> { /* private fields */ }
Expand description

A single unique libapt package.

Implementations§

Source§

impl<'a> Package<'a>

Source

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

Source

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

Source

pub fn inst_state(&self) -> PkgInstState

The installed state of this package.

Source

pub fn selected_state(&self) -> PkgSelectedState

The selected state of this package.

Source

pub fn current_state(&self) -> PkgCurrentState

The current state of this package.

Source

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

Returns the version object of the installed version.

If there isn’t an installed version, returns None

Source

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

Returns the version object of the candidate.

If there isn’t a candidate, returns None

Source

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.
Source

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

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 = PkgIterator>§

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 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 is_essential(&self) -> bool

True if the package is essential.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn index(&self) -> u64

Source

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.

Source

pub fn raw_next(self: Pin<&mut Self>)

Source

pub fn end(&self) -> bool

Trait Implementations§

Source§

impl<'a> Debug for Package<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

type Target = PkgIterator

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> Display for Package<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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> !Freeze for Package<'a>

§

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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

Source§

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.