pub struct DiskCache { /* private fields */ }Expand description
In-memory representation of a .oxcache file.
Implementations§
Source§impl DiskCache
impl DiskCache
Sourcepub fn add_entry(&mut self, entry: CacheEntry)
pub fn add_entry(&mut self, entry: CacheEntry)
Append an entry.
Sourcepub fn set_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn set_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
Set a metadata key-value pair.
Sourcepub fn get_metadata(&self, key: &str) -> Option<&str>
pub fn get_metadata(&self, key: &str) -> Option<&str>
Look up a metadata value.
Sourcepub fn get_entry(&self, name: &str) -> Option<&CacheEntry>
pub fn get_entry(&self, name: &str) -> Option<&CacheEntry>
Find an entry by name.
Sourcepub fn num_entries(&self) -> usize
pub fn num_entries(&self) -> usize
Number of entries.
Sourcepub fn total_data_bytes(&self) -> usize
pub fn total_data_bytes(&self) -> usize
Sum of all entry data sizes.
Sourcepub fn load(path: &Path) -> Result<Self, DiskCacheError>
pub fn load(path: &Path) -> Result<Self, DiskCacheError>
Load from a file path.
Sourcepub fn write_to<W: Write>(&self, writer: &mut W) -> Result<(), DiskCacheError>
pub fn write_to<W: Write>(&self, writer: &mut W) -> Result<(), DiskCacheError>
Serialize to an arbitrary writer.
Sourcepub fn read_from<R: Read>(reader: &mut R) -> Result<Self, DiskCacheError>
pub fn read_from<R: Read>(reader: &mut R) -> Result<Self, DiskCacheError>
Deserialize from an arbitrary reader.
Sourcepub fn is_valid_cache(path: &Path) -> bool
pub fn is_valid_cache(path: &Path) -> bool
Check if a cache file exists and has valid magic + version.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DiskCache
impl RefUnwindSafe for DiskCache
impl Send for DiskCache
impl Sync for DiskCache
impl Unpin for DiskCache
impl UnsafeUnpin for DiskCache
impl UnwindSafe for DiskCache
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> 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