Skip to main content

Cache

Struct Cache 

Source
pub struct Cache {
    pub(super) root: PathBuf,
    index: Index,
    pub(super) state: IndexState,
}

Fields§

§root: PathBuf§index: Index§state: IndexState

Implementations§

Source§

impl Cache

Source

pub fn open(root: impl Into<PathBuf>) -> Cache

An index that is missing or cannot be read opens as an empty cache and leaves the payloads on disk; index_state says which happened.

Source

pub fn index_state(&self) -> IndexState

Source

pub fn root(&self) -> &Path

Source

pub fn get(&self, key: &str) -> Option<&CachedPackage>

Source

pub fn entries(&self) -> Vec<CachedPackage>

Every entry whose payload is still on disk, so nothing missing is offered as downloaded.

Source

pub(super) fn names(&self, sha256: &str) -> bool

Whether an index entry names this payload.

Source

pub(super) fn known_digests(&self) -> BTreeSet<&str>

Source

pub fn insert(&mut self, package: CachedPackage) -> Result<()>

Saves at once, so an interrupted run keeps the download that just finished.

Source

pub fn remove(&mut self, key: &str) -> Result<()>

Source

pub fn save(&mut self) -> Result<()>

A temp file renamed over the old index, which std::fs::rename replaces in one step, so a crash never leaves the cache without one.

Source§

impl Cache

Source

pub fn payload_path(&self, sha256: &str) -> PathBuf

Where a payload with this digest lives, whether or not it is there.

Source

pub fn has_payload(&self, sha256: &str) -> bool

The index can outlive its file, so an install asks this rather than trusting the index.

Source

pub fn holds(&self, key: &str) -> bool

Whether key’s payload is here to install, not merely named by the index.

Source

pub fn orphans(&self) -> Vec<PathBuf>

Payloads no index entry refers to, for the I9 sweep, and none unless the index was really read, or a damaged index would condemn the whole cache.

Source

pub fn sweep(&self, in_use: Option<&[String]>) -> Swept

Deletes what a killed download left half-written, and, given in_use (the digests the ledger and the restore points need), every payload neither it nor the index names; None deletes no payload, for when what is needed is unknown, and so does an index that was not read.

Auto Trait Implementations§

§

impl Freeze for Cache

§

impl RefUnwindSafe for Cache

§

impl Send for Cache

§

impl Sync for Cache

§

impl Unpin for Cache

§

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