pub struct RefCounted<V> { /* private fields */ }Expand description
Table that tracks reference counts for shared resources.
Implementations§
Source§impl<V: Clone> RefCounted<V>
impl<V: Clone> RefCounted<V>
pub fn new() -> Self
Sourcepub fn insert(&mut self, key: &str, value: V) -> bool
pub fn insert(&mut self, key: &str, value: V) -> bool
Insert with initial ref-count of 1. Returns false if already exists.
Sourcepub fn acquire(&mut self, key: &str) -> Option<u32>
pub fn acquire(&mut self, key: &str) -> Option<u32>
Increment ref-count. Returns new count, or None if not found.
Sourcepub fn release(&mut self, key: &str) -> Option<u32>
pub fn release(&mut self, key: &str) -> Option<u32>
Decrement ref-count. Removes entry when count reaches 0. Returns remaining count, or None if not found.
pub fn get(&self, key: &str) -> Option<&V>
pub fn ref_count(&self, key: &str) -> Option<u32>
pub fn contains(&self, key: &str) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn total_refs(&self) -> u64
pub fn keys(&self) -> Vec<&str>
pub fn clear(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl<V> Freeze for RefCounted<V>
impl<V> RefUnwindSafe for RefCounted<V>where
V: RefUnwindSafe,
impl<V> Send for RefCounted<V>where
V: Send,
impl<V> Sync for RefCounted<V>where
V: Sync,
impl<V> Unpin for RefCounted<V>where
V: Unpin,
impl<V> UnsafeUnpin for RefCounted<V>
impl<V> UnwindSafe for RefCounted<V>where
V: UnwindSafe,
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