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_signature_policy(self, policy: SignaturePolicy) -> Self

With SignaturePolicy::Require, refuse every artifact whose manifest signature was not verified against a key in this cache’s TrustPolicy::EmbeddedKeys, instead of accepting a digest-only lock entry.

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 the stamp is honoured only while the cache root and its object directory are owned by the current user and not writable by group or others (Unix); otherwise every verification hashes the library. The cache creates its directories 0700.

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, and a damaged installed artifact with ComponentError::CachedObjectInvalid. 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 verify_cached( &self, entry: &ComponentLockEntry, ) -> Result<CachedArtifact, ComponentError>

Verify an installed object in place: checks it against the lock entry (skipping the library hash when a current verified stamp says it is unchanged) but never downloads or removes anything, and writes nothing but the verified stamp when the cache was built with [Self::with_verified_stamp(true)].

Unlike Self::install, a failing check is reported instead of repaired, and the error says which check failed (digest, size, manifest, signature) – so a caller can tell “installed and damaged” apart from “never installed” and log or report a repair.

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. Waits for an install of the same object in another thread or process to finish first.

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§

§

impl !RefUnwindSafe for ArtifactCache

§

impl !UnwindSafe for ArtifactCache

§

impl Forget for ArtifactCache

§

impl Freeze for ArtifactCache
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const LeafNode<String, String> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, String)>>: Freeze, *const ArcInner<dyn Fn(u64, u64) + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(u64, u64) + Sync + Send>>: Freeze, *const ArcInner<Atomic<bool>> is !null: Freeze, PhantomData<ArcInner<Atomic<bool>>>: Freeze, *const ArcInner<dyn Fn(&ComponentLockEntry) -> String + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&ComponentLockEntry) -> String + Sync + Send>>: Freeze,

§

impl Move for ArtifactCache

§

impl Send for ArtifactCache
where RawVecInner: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, Arc<dyn Fn(u64, u64) + Sync + Send>: Send, Arc<Atomic<bool>>: Send, Arc<dyn Fn(&ComponentLockEntry) -> String + Sync + Send>: Send,

§

impl Sync for ArtifactCache
where RawVecInner: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync, Arc<dyn Fn(u64, u64) + Sync + Send>: Sync, Arc<Atomic<bool>>: Sync, Arc<dyn Fn(&ComponentLockEntry) -> String + Sync + Send>: Sync,

§

impl Unpin for ArtifactCache
where *const u8 is !null: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, Arc<dyn Fn(u64, u64) + Sync + Send>: Unpin, Arc<Atomic<bool>>: Unpin, Arc<dyn Fn(&ComponentLockEntry) -> String + Sync + Send>: Unpin,

§

impl UnsafeUnpin for ArtifactCache
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<String, String> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, String)>>: UnsafeUnpin, *const ArcInner<dyn Fn(u64, u64) + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(u64, u64) + Sync + Send>>: UnsafeUnpin, *const ArcInner<Atomic<bool>> is !null: UnsafeUnpin, PhantomData<ArcInner<Atomic<bool>>>: UnsafeUnpin, *const ArcInner<dyn Fn(&ComponentLockEntry) -> String + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&ComponentLockEntry) -> String + Sync + Send>>: UnsafeUnpin,

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.