Skip to main content

ArtifactCache

Struct ArtifactCache 

Source
pub struct ArtifactCache { /* private fields */ }

Implementations§

Source§

impl ArtifactCache

Source

pub fn new(root: impl Into<PathBuf>, trust: TrustPolicy) -> Self

Source

pub fn with_download_options(self, options: DownloadOptions) -> Self

Replace the download tuning (timeouts, retries, progress, cancellation).

Source

pub fn download_options(&self) -> &DownloadOptions

Source

pub fn with_url_override( self, resolve: impl Fn(&ComponentLockEntry) -> String + Send + Sync + 'static, ) -> Self

Fetch artifacts from resolve(entry) instead of the lock entry’s own url.

Intended for air-gapped or corporate mirrors. Integrity never depends on the URL: the archive size, SHA-256 and the manifest signature are still checked against the lock. A returned file:// URL is read from disk.

Source

pub fn with_verified_stamp(self, enabled: bool) -> Self

Trust a verified stamp instead of re-hashing an installed library on every process start. Off by default.

After the first full check a stamp (archive sha, size, mtime in nanoseconds, and on Unix device, inode and ctime) is written next to the object. A later process that finds the library still matching the stamp skips reading and hashing it; the manifest digest, identity and signature are still verified every time.

Still caught: replacing the file (new inode), size changes, and edits that change the mtime or, on Unix, the ctime. Not caught: a same-size in-place edit that restores the mtime on Windows, or by an attacker who can forge Unix ctime. Anyone able to do that can already rewrite the cache (including the stamp), so enable this only for caches that only the current user can write.

Source

pub fn offline(self, offline: bool) -> Self

Disable network downloads: Self::install fails a missing artifact with ComponentError::Offline instead of attempting a request. An artifact already verified on disk (or served via a file:// URL) is unaffected.

Source

pub fn root(&self) -> &Path

Source

pub fn object_path( &self, entry: &ComponentLockEntry, ) -> Result<PathBuf, ComponentError>

Source

pub fn install( &self, entry: &ComponentLockEntry, ) -> Result<CachedArtifact, ComponentError>

Source

pub fn install_from_reader( &self, entry: &ComponentLockEntry, reader: impl Read, ) -> Result<CachedArtifact, ComponentError>

Install an archive from reader, honouring this cache’s progress and cancellation settings (see DownloadOptions). Never retries: the reader cannot be rewound.

Source§

impl ArtifactCache

Source

pub fn list_objects(&self) -> Result<Vec<CachedObject>, ComponentError>

Every installed object, sorted by digest. A missing cache directory lists as empty.

Source

pub fn remove_object( &self, sha256: &str, ) -> Result<RemovalReport, ComponentError>

Remove one object and its sidecar files. Ok with an empty report when absent.

Trait Implementations§

Source§

impl Clone for ArtifactCache

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ArtifactCache

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.