pub struct GenerationalPool { /* private fields */ }Expand description
A string pool that supports generational compaction.
When compact is called, unreferenced strings are removed and the
generation counter is incremented, invalidating old handles.
Implementations§
Source§impl GenerationalPool
impl GenerationalPool
Sourcepub fn intern(&mut self, s: &str) -> GenerationalString
pub fn intern(&mut self, s: &str) -> GenerationalString
Intern a string and return a generational handle.
Sourcepub fn release(&mut self, handle: GenerationalString)
pub fn release(&mut self, handle: GenerationalString)
Release a handle, decrementing its reference count.
Sourcepub fn resolve(&self, handle: GenerationalString) -> Option<&str>
pub fn resolve(&self, handle: GenerationalString) -> Option<&str>
Resolve a handle to its string content.
Sourcepub fn is_valid(&self, handle: GenerationalString) -> bool
pub fn is_valid(&self, handle: GenerationalString) -> bool
Check if a handle is still valid (correct generation and non-zero refcount).
Sourcepub fn compact(&mut self) -> usize
pub fn compact(&mut self) -> usize
Compact the pool: remove strings with zero reference count. All handles from the previous generation are invalidated.
Sourcepub fn generation(&self) -> u16
pub fn generation(&self) -> u16
Current generation counter.
Sourcepub fn live_count(&self) -> usize
pub fn live_count(&self) -> usize
Number of live strings (with ref_count > 0).
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Total strings in the pool (including those with rc=0).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GenerationalPool
impl RefUnwindSafe for GenerationalPool
impl Send for GenerationalPool
impl Sync for GenerationalPool
impl Unpin for GenerationalPool
impl UnsafeUnpin for GenerationalPool
impl UnwindSafe for GenerationalPool
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