pub struct FileMetadataCache { /* private fields */ }
Expand description
Cache for various metadata about files.
The cache is keyed by the file path and the type of metadata.
Implementations§
Source§impl FileMetadataCache
impl FileMetadataCache
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Instantiates a new cache which, for legacy reasons, uses Items capacity mode.
Sourcepub fn with_capacity(capacity: usize, mode: CapacityMode) -> Self
pub fn with_capacity(capacity: usize, mode: CapacityMode) -> Self
Instantiates a new cache with a given capacity and capacity mode.
Sourcepub fn with_base_path(&self, base_path: Path) -> Self
pub fn with_base_path(&self, base_path: Path) -> Self
Creates a new cache which shares the same underlying cache but prepends base_path
to all
keys.
pub fn size(&self) -> usize
pub fn get<T: Send + Sync + 'static>(&self, path: &Path) -> Option<Arc<T>>
pub fn insert<T: DeepSizeOf + Send + Sync + 'static>( &self, path: Path, metadata: Arc<T>, )
Sourcepub async fn get_or_insert<T: DeepSizeOf + Send + Sync + 'static, F, Fut>(
&self,
path: &Path,
loader: F,
) -> Result<Arc<T>>
pub async fn get_or_insert<T: DeepSizeOf + Send + Sync + 'static, F, Fut>( &self, path: &Path, loader: F, ) -> Result<Arc<T>>
Get an item
If it exists in the cache return that
If it doesn’t then run loader
to load the item, insert into cache, and return
Trait Implementations§
Source§impl Clone for FileMetadataCache
impl Clone for FileMetadataCache
Source§fn clone(&self) -> FileMetadataCache
fn clone(&self) -> FileMetadataCache
Returns a copy 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 moreSource§impl Debug for FileMetadataCache
impl Debug for FileMetadataCache
Source§impl DeepSizeOf for FileMetadataCache
impl DeepSizeOf for FileMetadataCache
Source§fn deep_size_of_children(&self, _: &mut Context) -> usize
fn deep_size_of_children(&self, _: &mut Context) -> usize
Returns an estimation of the heap-managed storage of this object.
This does not include the size of the object itself. Read more
Source§fn deep_size_of(&self) -> usize
fn deep_size_of(&self) -> usize
Returns an estimation of a total size of memory owned by the
object, including heap-managed storage. Read more
Auto Trait Implementations§
impl Freeze for FileMetadataCache
impl !RefUnwindSafe for FileMetadataCache
impl Send for FileMetadataCache
impl Sync for FileMetadataCache
impl Unpin for FileMetadataCache
impl !UnwindSafe for FileMetadataCache
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