pub struct BytecodeShaderCache {
pub cache: HashMap<String, Vec<u8>>,
pub max_size: usize,
/* private fields */
}Expand description
Cache for compiled shader bytecode (mock compiled blobs).
Supports a maximum total byte budget; when the budget is exceeded,
evict_oldest removes the oldest-inserted entry.
Fields§
§cache: HashMap<String, Vec<u8>>Map from shader name to compiled bytecode.
max_size: usizeMaximum total bytes allowed.
Implementations§
Source§impl BytecodeShaderCache
impl BytecodeShaderCache
Sourcepub fn insert(&mut self, name: &str, bytecode: Vec<u8>)
pub fn insert(&mut self, name: &str, bytecode: Vec<u8>)
Insert (or replace) a shader’s compiled bytecode.
If the total size would exceed max_size, evict_oldest is called
before inserting.
Sourcepub fn evict_oldest(&mut self)
pub fn evict_oldest(&mut self)
Evict the oldest cached entry. No-op if cache is empty.
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Total bytes currently stored across all cached entries.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BytecodeShaderCache
impl RefUnwindSafe for BytecodeShaderCache
impl Send for BytecodeShaderCache
impl Sync for BytecodeShaderCache
impl Unpin for BytecodeShaderCache
impl UnsafeUnpin for BytecodeShaderCache
impl UnwindSafe for BytecodeShaderCache
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> 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