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

A struct representing an apt Package

Implementations

Get the fullname of the package.

Pretty is a bool that will omit the native arch.

For example on an amd64 system:

use rust_apt::cache::Cache;
let cache = Cache::new();
if let Some(pkg) = cache.get("apt") {
   // Prints just "apt"
   println!("{}", pkg.fullname(true));
   // Prints "apt:amd64"
   println!("{}", pkg.fullname(false));
};

if let Some(pkg) = cache.get("apt:i386") {
   // Prints "apt:i386" for the i386 package
   println!("{}", pkg.fullname(true));
};

Return the name of the package without the architecture

Get the architecture of the package.

Get the ID of the package.

The current state of the package.

The installed state of the package.

The selected state of the package.

Check if the package is essential or not.

Check if the package has versions.

Check if the package has provides.

The list of packages that provide this package.

version_rel:
  • Some = A tuple representing the version and operator (i.e. ("1.0.0", ">=")).
  • None = No version/operator qualifier will be used.

If an invalid operator is passed when using the Some variant (anything other than <<, <=, =, >=, and >>), than this function will panic.

This function searches the cache for any packages that provide this package. It is meant to get the list of packages that satisfy a dependency string. Take this example from a control file:

\# Example 1:
Depends: apt-transport-https (= 5)
\# Example 2:
Depends: apt-transport-https

If version_rel is None, then any packages that contain Provides: apt-transport-https will be unable to satisfy example 1, as per Debian policy. If version_rel is Some on the other hand, then this function will make sure any packages matching the provides entry (i.e. Provides: apt-transport-https (= 5)) fit into the version requirement. E.g. if (">=", "6.0.0") was provided, then the previous example of Provides: apt-transport-https (= 5) would not be returned, since it didn’t fit the requirements of being greater than or equal to 6.0.0.

Returns:

A vector of matching Version structs.

If you need to see what packages this package provides for, use a version from Package::candidate or Package::versions and call Version::provides_list instead.

NOTE: This function is currently fairly expensive to run (~300 milliseconds on an Intel i5), and may dramatically slow down your program if called too much.

Returns the version object of the candidate.

If there isn’t a candidate, returns None

Returns the version object of the installed version.

If there isn’t an installed version, returns None

Return either a Version or None

Example:
use rust_apt::cache::Cache;

let cache = Cache::new();
let pkg = cache.get("apt").unwrap();

pkg.get_version("2.4.7");

Check if the package is installed.

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

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

Check if the package is auto removable

Check if the package is now broken

Check if the package package installed is broken

Check if the package is marked install

Check if the package is marked upgrade

Check if the package is marked purge

Check if the package is marked delete

Check if the package is marked keep

Check if the package is marked downgrade

Check if the package is marked reinstall

Get the state of a package based on a Mark

Returns:
  • true if the state matches the Mark
  • false if the state doesn’t match the Mark
Example
use rust_apt::cache::Cache;
use rust_apt::package::Mark;

let cache = Cache::new();
let pkg = cache.get("apt").unwrap();

if pkg.state(&Mark::Auto) {
    println!("Package is automatically installed")
} else {
    println!("Package is manually installed")
}

Set a Mark on a package using the Mark enum

Returns:
  • true if the mark was successful
  • false if the mark was unsuccessful
Note:

There are some cases where a mark is successful, but nothing will change.

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. get(Mark::Install) will be false

Example
use rust_apt::cache::Cache;
use rust_apt::package::Mark;

let cache = Cache::new();
let pkg = cache.get("apt").unwrap();

if pkg.set(&Mark::Purge) {
    println!("Package will be purged")
} else {
    println!("Package was unable to be purged")
}
Mark a package as automatically installed.
mark_auto:
  • true = Mark the package as automatically installed.
  • false = Mark the package as manually installed.
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.

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

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.

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

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

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.