pub struct StringInterner { /* private fields */ }
Expand description
A thread-safe string interner that deduplicates strings with ID mapping
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 specified capacity
Sourcepub fn intern(&self, s: &str) -> Arc<str>
pub fn intern(&self, s: &str) -> Arc<str>
Intern a string, returning an Arc
Sourcepub fn intern_with_id(&self, s: &str) -> (Arc<str>, u32)
pub fn intern_with_id(&self, s: &str) -> (Arc<str>, u32)
Intern a string and return both the Arc
Sourcepub fn get_all_mappings(&self) -> Vec<(u32, Arc<str>)>
pub fn get_all_mappings(&self) -> Vec<(u32, Arc<str>)>
Get all ID mappings (useful for serialization/debugging)
Sourcepub fn stats(&self) -> InternerStats
pub fn stats(&self) -> InternerStats
Get current statistics
Sourcepub fn id_mapping_count(&self) -> usize
pub fn id_mapping_count(&self) -> usize
Get the number of strings with ID mappings
Sourcepub fn intern_batch(&self, strings: &[&str]) -> Vec<Arc<str>>
pub fn intern_batch(&self, strings: &[&str]) -> Vec<Arc<str>>
Batch intern multiple strings for improved performance
Returns a Vec of Arc
Sourcepub fn prefetch(&self, strings: &[&str])
pub fn prefetch(&self, strings: &[&str])
Prefetch strings into the interner cache for improved performance This is useful when you know you’ll need certain strings soon
Sourcepub fn memory_usage(&self) -> MemoryUsage
pub fn memory_usage(&self) -> MemoryUsage
Get memory usage statistics for performance monitoring
Trait Implementations§
Source§impl Debug for StringInterner
impl Debug for StringInterner
Auto Trait Implementations§
impl !Freeze for StringInterner
impl RefUnwindSafe for StringInterner
impl Send for StringInterner
impl Sync for StringInterner
impl Unpin for StringInterner
impl UnwindSafe 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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