pub struct StringInterner { /* private fields */ }Expand description
Thread-safe string interner for deduplicating repeated string values
This implementation uses Arc to share string data across multiple references, significantly reducing memory usage when the same strings appear multiple times (common in BPSV config files).
Implementations§
Source§impl StringInterner
impl StringInterner
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new string interner with pre-allocated capacity
Sourcepub fn intern(&self, s: &str) -> Arc<String>
pub fn intern(&self, s: &str) -> Arc<String>
Intern a string, returning an Arc to the shared instance
If the string already exists in the pool, returns the existing Arc. Otherwise, adds it to the pool and returns a new Arc.
Sourcepub fn intern_owned(&self, s: String) -> Arc<String>
pub fn intern_owned(&self, s: String) -> Arc<String>
Intern a string that we already own
Sourcepub fn unique_count(&self) -> usize
pub fn unique_count(&self) -> usize
Get the number of unique strings in the pool
Sourcepub fn memory_usage(&self) -> MemoryStats
pub fn memory_usage(&self) -> MemoryStats
Get memory statistics
Trait Implementations§
Source§impl Clone for StringInterner
impl Clone for StringInterner
Source§fn clone(&self) -> StringInterner
fn clone(&self) -> StringInterner
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StringInterner
impl Debug for StringInterner
Auto Trait Implementations§
impl !RefUnwindSafe for StringInterner
impl !UnwindSafe for StringInterner
impl Freeze for StringInterner
impl Send for StringInterner
impl Sync for StringInterner
impl Unpin for StringInterner
impl UnsafeUnpin for StringInterner
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