pub struct Version<'a> { /* private fields */ }
Expand description
Represents a single Version of a package.
Implementations§
Source§impl<'a> Version<'a>
impl<'a> Version<'a>
pub fn new(ptr: UniquePtr<VerIterator>, cache: &'a Cache) -> Version<'a>
pub fn version_files(&self) -> impl Iterator<Item = VersionFile<'a>>
Sourcepub fn package_files(&self) -> impl Iterator<Item = PackageFile<'a>>
pub fn package_files(&self) -> impl Iterator<Item = PackageFile<'a>>
Returns an iterator of PackageFiles (Origins) for the version
Sourcepub fn depends_map(&self) -> &HashMap<DepType, Vec<Dependency<'a>>>
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())
}
}
Sourcepub fn get_depends(&self, key: &DepType) -> Option<&Vec<Dependency<'a>>>
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.
Sourcepub fn enhances(&self) -> Option<&Vec<Dependency<'a>>>
pub fn enhances(&self) -> Option<&Vec<Dependency<'a>>>
Returns a Reference Vector, if it exists, for “Enhances”.
Sourcepub fn dependencies(&self) -> Option<Vec<&Dependency<'a>>>
pub fn dependencies(&self) -> Option<Vec<&Dependency<'a>>>
Returns a Reference Vector, if it exists, for “Depends” and “PreDepends”.
Sourcepub fn recommends(&self) -> Option<&Vec<Dependency<'a>>>
pub fn recommends(&self) -> Option<&Vec<Dependency<'a>>>
Returns a Reference Vector, if it exists, for “Recommends”.
Sourcepub fn suggests(&self) -> Option<&Vec<Dependency<'a>>>
pub fn suggests(&self) -> Option<&Vec<Dependency<'a>>>
Returns a Reference Vector, if it exists, for “suggests”.
Sourcepub fn description(&self) -> Option<String>
pub fn description(&self) -> Option<String>
Get the translated long description
Sourcepub fn get_record<T: ToString + ?Sized>(&self, field: &T) -> Option<String>
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());
Sourcepub fn hash<T: ToString + ?Sized>(&self, hash_type: &T) -> Option<String>
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")
Sourcepub fn sha256(&self) -> Option<String>
pub fn sha256(&self) -> Option<String>
Get the sha256 hash. If there isn’t one returns None
This is equivalent to version.hash("sha256")
Sourcepub fn sha512(&self) -> Option<String>
pub fn sha512(&self) -> Option<String>
Get the sha512 hash. If there isn’t one returns None
This is equivalent to version.hash("sha512")
Sourcepub fn uris(&self) -> impl Iterator<Item = String> + 'a
pub fn uris(&self) -> impl Iterator<Item = String> + 'a
Returns an Iterator of URIs for the Version.
Sourcepub fn set_candidate(&self)
pub fn set_candidate(&self)
Set this version as the candidate.
Methods from Deref<Target = VerIterator>§
Sourcepub unsafe fn parent_pkg(&self) -> UniquePtr<PkgIterator>
pub unsafe fn parent_pkg(&self) -> UniquePtr<PkgIterator>
Sourcepub fn section(&self) -> Result<&str, Exception>
pub fn section(&self) -> Result<&str, Exception>
The section of the version as shown in apt show
.
Sourcepub fn priority_str(&self) -> Result<&str, Exception>
pub fn priority_str(&self) -> Result<&str, Exception>
The priority string as shown in apt show
.
Sourcepub fn installed_size(&self) -> u64
pub fn installed_size(&self) -> u64
The uncompressed size of the .deb file.
Sourcepub fn is_downloadable(&self) -> bool
pub fn is_downloadable(&self) -> bool
True if the version is able to be downloaded.
Sourcepub fn is_installed(&self) -> bool
pub fn is_installed(&self) -> bool
True if the version is currently installed
Sourcepub fn source_name(&self) -> &str
pub fn source_name(&self) -> &str
Always contains the name, even if it is the same as the binary name
pub fn source_version(&self) -> &str
Sourcepub unsafe fn provides(&self) -> UniquePtr<PrvIterator>
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.
Sourcepub unsafe fn depends(&self) -> UniquePtr<DepIterator>
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.
Sourcepub unsafe fn version_files(&self) -> UniquePtr<VerFileIterator>
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.
Sourcepub unsafe fn translated_desc(&self) -> UniquePtr<DescIterator>
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.