pub struct Cache {
pub root: PathBuf,
}Expand description
The on-disk package cache, rooted at Cache::root.
Fields§
§root: PathBufImplementations§
Source§impl Cache
impl Cache
Sourcepub fn user_default() -> Cache
pub fn user_default() -> Cache
The cache rooted at ~/.ridl/cache (ADR-0002 §7). When the home
directory is unknown it falls back to .ridl/cache relative to the
current directory.
Sourcepub fn lookup(&self, url: &str, sha256: &str) -> Option<PathBuf>
pub fn lookup(&self, url: &str, sha256: &str) -> Option<PathBuf>
The unpacked package directory for url pinned to sha256, if it is
present in the cache. A hit means the artifact with that content hash is
already unpacked, so no fetch is needed.
Sourcepub fn store(&self, url: &str, bytes: &[u8]) -> Result<(String, PathBuf)>
pub fn store(&self, url: &str, bytes: &[u8]) -> Result<(String, PathBuf)>
Stores the artifact bytes fetched from url, unpacking the tar into
the content-addressed entry directory. Returns the artifact’s SHA-256
content hash (lowercase hex) and the unpacked directory.
The tar is unpacked into a temporary sibling directory and then renamed
into place, so a fetch interrupted mid-unpack never leaves a partial
directory that a later lookup would treat as a hit. A
re-store of already-cached content is a no-op that returns the existing
directory.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more