pub struct MaterialCache { /* private fields */ }Expand description
Content-addressable, LRU-evicting cache for PbrMaterial values.
Materials are stored by their structural hash (MaterialKey). When the
cache is full the least-recently-used entry is evicted.
Implementations§
Source§impl MaterialCache
impl MaterialCache
Sourcepub fn insert(&mut self, material: PbrMaterial) -> MaterialKey
pub fn insert(&mut self, material: PbrMaterial) -> MaterialKey
Insert (or refresh) a material. Returns the MaterialKey for later
retrieval. If the cache is full the LRU entry is evicted first.
Sourcepub fn get(&mut self, key: MaterialKey) -> Option<&PbrMaterial>
pub fn get(&mut self, key: MaterialKey) -> Option<&PbrMaterial>
Retrieve a previously inserted material by key.
Sourcepub fn peek(&self, key: MaterialKey) -> Option<&PbrMaterial>
pub fn peek(&self, key: MaterialKey) -> Option<&PbrMaterial>
Peek at a material without updating the LRU counter.
Sourcepub fn remove(&mut self, key: MaterialKey) -> bool
pub fn remove(&mut self, key: MaterialKey) -> bool
Remove a material from the cache.
Sourcepub fn insert_batch(
&mut self,
materials: impl IntoIterator<Item = PbrMaterial>,
) -> Vec<MaterialKey>
pub fn insert_batch( &mut self, materials: impl IntoIterator<Item = PbrMaterial>, ) -> Vec<MaterialKey>
Pre-populate the cache with a slice of materials. Returns the keys.
Sourcepub fn iter(&self) -> impl Iterator<Item = (MaterialKey, &PbrMaterial)>
pub fn iter(&self) -> impl Iterator<Item = (MaterialKey, &PbrMaterial)>
Iterate over all cached materials in arbitrary order.
Auto Trait Implementations§
impl Freeze for MaterialCache
impl RefUnwindSafe for MaterialCache
impl Send for MaterialCache
impl Sync for MaterialCache
impl Unpin for MaterialCache
impl UnsafeUnpin for MaterialCache
impl UnwindSafe for MaterialCache
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