pub struct ContentCache { /* private fields */ }Expand description
Content-addressable cache for storing package tarballs
Implementations§
Source§impl ContentCache
impl ContentCache
Sourcepub fn new(root: Option<PathBuf>) -> Self
pub fn new(root: Option<PathBuf>) -> Self
Create a new ContentCache with the given root directory If root is None, uses the default cache directory
Sourcepub fn default_cache_dir() -> PathBuf
pub fn default_cache_dir() -> PathBuf
Get the default cache directory (~/.dnx/cache)
Sourcepub fn content_dir(&self) -> PathBuf
pub fn content_dir(&self) -> PathBuf
Get the content directory path
Sourcepub fn has(&self, integrity: &str) -> bool
pub fn has(&self, integrity: &str) -> bool
Check if content with the given integrity exists in the cache (O(1) memory lookup)
Sourcepub fn get_path(&self, integrity: &str) -> PathBuf
pub fn get_path(&self, integrity: &str) -> PathBuf
Get the path to cached content for the given integrity
Sourcepub fn store(&self, integrity: &str, tarball_data: &[u8]) -> Result<PathBuf>
pub fn store(&self, integrity: &str, tarball_data: &[u8]) -> Result<PathBuf>
Store tarball data in the cache after verifying its integrity Returns the path to the extracted package directory
Sourcepub fn disk_usage(&self) -> Result<u64>
pub fn disk_usage(&self) -> Result<u64>
Calculate the total disk usage of the cache
Trait Implementations§
Source§impl Clone for ContentCache
impl Clone for ContentCache
Source§fn clone(&self) -> ContentCache
fn clone(&self) -> ContentCache
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ContentCache
impl RefUnwindSafe for ContentCache
impl Send for ContentCache
impl Sync for ContentCache
impl Unpin for ContentCache
impl UnsafeUnpin for ContentCache
impl UnwindSafe for ContentCache
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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