pub struct AudioCache { /* private fields */ }Expand description
A least-recently-used cache that skips entries with external references. See the module documentation for budget accounting and thread responsibilities.
Implementations§
Source§impl AudioCache
impl AudioCache
Sourcepub fn new(budget_bytes: usize) -> Self
pub fn new(budget_bytes: usize) -> Self
An empty cache with a retained-data budget in bytes. Zero disables admission.
pub fn budget_bytes(&self) -> usize
Sourcepub fn used_bytes(&self) -> usize
pub fn used_bytes(&self) -> usize
Accounted bytes of retained entries, including those pinned by callers.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn get(&mut self, key: &AssetKey) -> Option<Arc<Audio>>
pub fn get(&mut self, key: &AssetKey) -> Option<Arc<Audio>>
Get a shared sound and make its entry most recently used.
Sourcepub fn insert(&mut self, key: AssetKey, audio: Arc<Audio>) -> Result<()>
pub fn insert(&mut self, key: AssetKey, audio: Arc<Audio>) -> Result<()>
Admit a sound, evicting unused entries in LRU order as needed.
Returns LimitExceeded without changing entries when the sound is too large,
all sufficient victims are pinned, or replacing a different pinned sound.
Inserting the same Arc at its existing key only refreshes recency.
Auto Trait Implementations§
impl Freeze for AudioCache
impl RefUnwindSafe for AudioCache
impl Send for AudioCache
impl Sync for AudioCache
impl Unpin for AudioCache
impl UnsafeUnpin for AudioCache
impl UnwindSafe for AudioCache
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