Struct Version

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

Represents a single Version of a package.

Implementations§

Source§

impl<'a> Version<'a>

Source

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

Source

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

Returns a list of providers

Source

pub fn version_files(&self) -> impl Iterator<Item = VersionFile<'a>>

Source

pub fn package_files(&self) -> impl Iterator<Item = PackageFile<'a>>

Returns an iterator of PackageFiles (Origins) for the version

Source

pub fn parent(&self) -> Package<'a>

Return the version’s parent package.

Source

pub fn depends_map(&self) -> &HashMap<DepType, Vec<Dependency<'a>>>

Returns a reference to the Dependency Map owned by the Version

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, DepType};
let cache = new_cache!().unwrap();
let pkg = cache.get("apt").unwrap();
let version = pkg.candidate().unwrap();
for dep in version.depends_map().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_depends(&self, key: &DepType) -> Option<&Vec<Dependency<'a>>>

Returns a reference Vector, if it exists, for the given key.

See the doc for depends_map() for more information.

Source

pub fn enhances(&self) -> Option<&Vec<Dependency<'a>>>

Returns a Reference Vector, if it exists, for “Enhances”.

Source

pub fn dependencies(&self) -> Option<Vec<&Dependency<'a>>>

Returns a Reference Vector, if it exists, for “Depends” and “PreDepends”.

Source

pub fn recommends(&self) -> Option<&Vec<Dependency<'a>>>

Returns a Reference Vector, if it exists, for “Recommends”.

Source

pub fn suggests(&self) -> Option<&Vec<Dependency<'a>>>

Returns a Reference Vector, if it exists, for “suggests”.

Source

pub fn description(&self) -> Option<String>

Get the translated long description

Source

pub fn summary(&self) -> Option<String>

Get the translated short description

Source

pub fn get_record<T: ToString + ?Sized>(&self, field: &T) -> Option<String>

Get data from the specified record field

§Returns:
  • Some String or None if the field doesn’t exist.
§Example:
use rust_apt::new_cache;
use rust_apt::records::RecordField;

let cache = new_cache!().unwrap();
let pkg = cache.get("apt").unwrap();
let cand = pkg.candidate().unwrap();

println!("{}", cand.get_record(RecordField::Maintainer).unwrap());
// Or alternatively you can just pass any string
println!("{}", cand.get_record("Description-md5").unwrap());
Source

pub fn hash<T: ToString + ?Sized>(&self, hash_type: &T) -> Option<String>

Get the hash specified. If there isn’t one returns None version.hash("md5sum")

Source

pub fn sha256(&self) -> Option<String>

Get the sha256 hash. If there isn’t one returns None This is equivalent to version.hash("sha256")

Source

pub fn sha512(&self) -> Option<String>

Get the sha512 hash. If there isn’t one returns None This is equivalent to version.hash("sha512")

Source

pub fn uris(&self) -> impl Iterator<Item = String> + 'a

Returns an Iterator of URIs for the Version.

Source

pub fn set_candidate(&self)

Set this version as the candidate.

Source

pub fn priority(&self) -> i32

The priority of the Version as shown in apt policy.

Methods from Deref<Target = VerIterator>§

Source

pub fn version(&self) -> &str

The version string of the version. “1.4.10”.

Source

pub fn arch(&self) -> &str

The Arch of the version. “amd64”.

Source

pub unsafe fn parent_pkg(&self) -> UniquePtr<PkgIterator>

Return the version’s parent PkgIterator.

§Safety

The returned UniquePtr cannot outlive the cache.

Source

pub fn section(&self) -> Result<&str, Exception>

The section of the version as shown in apt show.

Source

pub fn priority_str(&self) -> Result<&str, Exception>

The priority string as shown in apt show.

Source

pub fn size(&self) -> u64

The size of the .deb file.

Source

pub fn installed_size(&self) -> u64

The uncompressed size of the .deb file.

Source

pub fn is_downloadable(&self) -> bool

True if the version is able to be downloaded.

Source

pub fn is_installed(&self) -> bool

True if the version is currently installed

Source

pub fn source_name(&self) -> &str

Always contains the name, even if it is the same as the binary name

Source

pub fn source_version(&self) -> &str

Source

pub unsafe fn provides(&self) -> UniquePtr<PrvIterator>

Return Providers Iterator

§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 depends(&self) -> UniquePtr<DepIterator>

Return Dependency Iterator

§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 version_files(&self) -> UniquePtr<VerFileIterator>

Return the version files. You go through here to get the package files.

§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 translated_desc(&self) -> UniquePtr<DescIterator>

This is for backend records lookups.

§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<VerIterator>

Clone the pointer.

§Safety

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 Version<'a>

Source§

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

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

impl<'a> Deref for Version<'a>

Source§

type Target = VerIterator

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<'a> Display for Version<'a>

Source§

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

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

impl<'a> Hash for Version<'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 Version<'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> PartialOrd for Version<'a>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> Eq for Version<'a>

Auto Trait Implementations§

§

impl<'a> !Freeze for Version<'a>

§

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

§

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

§

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

§

impl<'a> Unpin for Version<'a>

§

impl<'a> !UnwindSafe for Version<'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.