pub struct IconCache { /* private fields */ }Expand description
In-memory cache of rasterized Lucide / Devicon / SVG icons.
Entries live for the lifetime of the cache; there is no eviction. SVG parse failure is cached as a transparent square, and unsupported Devicons use the framework’s generic-file glyph.
§Examples
use ailloli_ui_render_wgpu::icons::IconCache;
let cache = IconCache::new();
let _ = cache;Implementations§
Source§impl IconCache
impl IconCache
Sourcepub fn get_or_create(
&mut self,
device: &Device,
queue: &Queue,
bind_group_layout: &BindGroupLayout,
key: &IconKey,
) -> &IconGpu
pub fn get_or_create( &mut self, device: &Device, queue: &Queue, bind_group_layout: &BindGroupLayout, key: &IconKey, ) -> &IconGpu
Returns the cached GPU icon or rasterizes and uploads it once.
key.px_size is clamped upward to eight for allocation and rasterization,
while the original key is retained. The returned reference remains valid
until the cache is mutably borrowed again.
§Panics
Panics on impossible cache inconsistency or GPU allocation validation failure. Invalid SVG itself produces a transparent texture instead.
§Examples
use ailloli_ui_render_wgpu::{icons::IconCache, IconKey};
fn upload<'a>(cache: &'a mut IconCache, device: &wgpu::Device,
queue: &wgpu::Queue, layout: &wgpu::BindGroupLayout,
key: &IconKey) -> &'a ailloli_ui_render_wgpu::icons::IconGpu {
cache.get_or_create(device, queue, layout, key)
}Sourcepub fn get(&self, key: &IconKey) -> Option<&IconGpu>
pub fn get(&self, key: &IconKey) -> Option<&IconGpu>
Looks up a previously uploaded icon without mutating the cache.
Returns None before Self::get_or_create has inserted the exact key.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_render_wgpu::{icons::IconCache, IconKey};
let cache = IconCache::new();
let key = IconKey { icon: IconId::Plus, px_size: 16, scale_100: 100 };
assert!(cache.get(&key).is_none());Trait Implementations§
Auto Trait Implementations§
impl Freeze for IconCache
impl !RefUnwindSafe for IconCache
impl Send for IconCache
impl Sync for IconCache
impl Unpin for IconCache
impl !UnwindSafe for IconCache
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
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>
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>
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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().