Struct Cache

Source
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

Source

pub fn get_singleton() -> Cache

Get a reference to the singleton.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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);

Trait Implementations§

Source§

impl Debug for Cache

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Cache

§

impl RefUnwindSafe for Cache

§

impl Send for Cache

§

impl Sync for Cache

§

impl Unpin for Cache

§

impl UnwindSafe for Cache

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