pub struct ArtifactCache { /* private fields */ }Implementations§
Source§impl ArtifactCache
impl ArtifactCache
pub fn new(root: impl Into<PathBuf>, trust: TrustPolicy) -> Self
Sourcepub fn with_download_options(self, options: DownloadOptions) -> Self
pub fn with_download_options(self, options: DownloadOptions) -> Self
Replace the download tuning (timeouts, retries, progress, cancellation).
pub fn download_options(&self) -> &DownloadOptions
Sourcepub fn with_url_override(
self,
resolve: impl Fn(&ComponentLockEntry) -> String + Send + Sync + 'static,
) -> Self
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.
Sourcepub fn with_verified_stamp(self, enabled: bool) -> Self
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.
Sourcepub fn offline(self, offline: bool) -> Self
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.
pub fn root(&self) -> &Path
pub fn object_path( &self, entry: &ComponentLockEntry, ) -> Result<PathBuf, ComponentError>
pub fn install( &self, entry: &ComponentLockEntry, ) -> Result<CachedArtifact, ComponentError>
Sourcepub fn install_from_reader(
&self,
entry: &ComponentLockEntry,
reader: impl Read,
) -> Result<CachedArtifact, ComponentError>
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
impl ArtifactCache
Sourcepub fn list_objects(&self) -> Result<Vec<CachedObject>, ComponentError>
pub fn list_objects(&self) -> Result<Vec<CachedObject>, ComponentError>
Every installed object, sorted by digest. A missing cache directory lists as empty.
Sourcepub fn remove_object(
&self,
sha256: &str,
) -> Result<RemovalReport, ComponentError>
pub fn remove_object( &self, sha256: &str, ) -> Result<RemovalReport, ComponentError>
Remove one object and its sidecar files. Ok with an empty report when absent.