pub struct Cache { /* private fields */ }Expand description
A reference to the package cache singleton, from which most functionality can be accessed.
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn get_singleton() -> Cache
pub fn get_singleton() -> Cache
Get a reference to the singleton.
Sourcepub fn reload(&mut self)
pub fn reload(&mut self)
Drop the cache, and re-create it from scratch.
It’s super important that there are no other outstanding references to the cache at this point. Again, I remind you not to try and outsmart the borrow checker. It doesn’t know how much trouble there is in here.
Sourcepub fn iter(&mut self) -> CIterator<PkgIterator<'_>>
pub fn iter(&mut self) -> CIterator<PkgIterator<'_>>
Walk through all of the packages, in a random order.
If there are multiple architectures, multiple architectures will be returned.
See the module documentation for apologies about how this isn’t an iterator.
Sourcepub fn find_by_name(&mut self, name: &str) -> CIterator<PkgIterator<'_>>
pub fn find_by_name(&mut self, name: &str) -> CIterator<PkgIterator<'_>>
Find a package by name. It’s not clear whether this picks a random arch, or the primary one.
The returned iterator will either be at the end, or at a package with the name.
Sourcepub fn find_by_name_arch(
&mut self,
name: &str,
arch: &str,
) -> CIterator<PkgIterator<'_>>
pub fn find_by_name_arch( &mut self, name: &str, arch: &str, ) -> CIterator<PkgIterator<'_>>
Find a package by name and architecture.
The returned iterator will either be at the end, or at a matching package.
Sourcepub fn compare_versions(&self, left: &str, right: &str) -> Ordering
pub fn compare_versions(&self, left: &str, right: &str) -> Ordering
Compare two versions, returning an Ordering, as used by most Rusty sort() methods.
This uses the “versioning scheme” currently set, which, in theory, can change, but in practice is always the “Standard .deb” scheme. As of 2017, there aren’t even any other implementations. As such, this may eventually become a static method somewhere.
§Examples
let mut packages = vec!["3.0", "3.1", "3.0~1"];
packages.sort_by(|left, right| cache.compare_versions(left, right));
assert_eq!(vec!["3.0~1", "3.0", "3.1"], packages);