Struct ImageViewCache

Source
pub struct ImageViewCache { /* private fields */ }
Expand description

Cache for image views This cache uses eviction strategy of ResourceCache. But has convenience methods for fetching image views.

Implementations§

Source§

impl ImageViewCache

Source

pub const fn new() -> Self

Creates a new empty cache.

Source

pub fn with_capacity(cap: usize) -> Self

Creates a new cache with preallocated resource capacity.

Source

pub fn fetch_image(&mut self, image: &Image) -> Option<&ImageView>

Fetches image view for specified image. Returns None if image is not in cache. Returns Some if image is in cache.

Source

pub fn fetch_image_view(&mut self, info: &ImageViewInfo) -> Option<&ImageView>

Fetches image view for specified image. Returns None if image is not in cache. Returns Some if image is in cache.

Source

pub fn make_image( &mut self, image: &Image, device: &Device, ) -> Result<&ImageView, OutOfMemory>

Fetches image view for specified image. Returns None if image is not in cache. Returns Some if image is in cache.

Source

pub fn make_image_view( &mut self, info: &ImageViewInfo, device: &Device, ) -> Result<&ImageView, OutOfMemory>

Fetches image view for specified image view info. Returns None if image is not in cache. Returns Some if image is in cache.

Methods from Deref<Target = ResourceCache<ImageView>>§

Source

pub fn fetch<F>(&mut self, eq: F) -> Option<&T>
where F: Fn(&T) -> bool,

Fetches resource from cache. Resource last used epoch is updated to the current epoch. Returns None if resource is not in cache. Returns Some if resource is in cache.

Source

pub fn get<Q>(&mut self, key: &Q) -> Option<&T>
where T: Borrow<Q>, Q: ?Sized + Hash + Eq,

Fetches resource from cache. Resource last used epoch is updated to the current epoch. Returns None if resource is not in cache. Returns Some if resource is in cache.

Source

pub fn fetch_no_update<F>(&self, eq: F) -> Option<&T>
where F: Fn(&T) -> bool,

Fetches resource from cache. Resource last used epoch is not updated. This is useful when only shared reference to cache is available. Returns None if resource is not in cache. Returns Some if resource is in cache.

Source

pub fn get_no_update<Q>(&self, key: &Q) -> Option<&T>
where T: Borrow<Q>, Q: ?Sized + Hash + Eq,

Fetches resource from cache. Resource last used epoch is not updated. This is useful when only shared reference to cache is available. Returns None if resource is not in cache. Returns Some if resource is in cache.

Source

pub fn try_fetch_or_create<K, F, E>( &mut self, eq: K, create: F, ) -> Result<&T, E>
where K: Fn(&T) -> bool, F: FnOnce() -> Result<T, E>,

Fetches resource from cache. Resource last used epoch is updated to the current epoch. If resource is not in cache, it is created and added to the cache. Returns a reference to the resource. Returns error if resource is not in cache and create function fails.

Source

pub fn fetch_or_create<E, F>(&mut self, eq: E, create: F) -> &T
where E: Fn(&T) -> bool, F: FnOnce() -> T,

Fetches resource from cache. Resource last used epoch is updated to the current epoch. If resource is not in cache, it is created and added to the cache. Returns a reference to the resource.

Source

pub fn try_get_or_create<Q, F, E>( &mut self, key: &Q, create: F, ) -> Result<&T, E>
where T: Borrow<Q>, Q: ?Sized + Hash + Eq, F: FnOnce() -> Result<T, E>,

Fetches resource from cache. Resource last used epoch is updated to the current epoch. If resource is not in cache, it is created and added to the cache. Returns a reference to the resource.

Source

pub fn get_or_create<Q, F>(&mut self, key: &Q, create: F) -> &T
where T: Borrow<Q>, Q: ?Sized + Hash + Eq, F: FnOnce() -> T,

Fetches resource from cache. Resource last used epoch is updated to the current epoch. If resource is not in cache, it is created and added to the cache. Returns a reference to the resource.

Source

pub fn next_epoch(&mut self)

Moves to the next epoch.

Source

pub fn evict(&mut self, epoch: u64)

Evicts resources that have not been used since specified epoch.

Trait Implementations§

Source§

impl Debug for ImageViewCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for ImageViewCache

Source§

type Target = ResourceCache<ImageView>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for ImageViewCache

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.