pub struct ArenaStr { /* private fields */ }Expand description
Interning arena for strings.
Implementations§
Source§impl ArenaStr
impl ArenaStr
Sourcepub fn with_capacity(strings: usize, bytes: usize) -> Self
pub fn with_capacity(strings: usize, bytes: usize) -> Self
Creates a new arena with pre-allocated space to store at least the given number of strings, totalling the given number of bytes.
Sourcepub fn strings(&self) -> usize
pub fn strings(&self) -> usize
Returns the number of strings in this arena.
Note that because ArenaStr is a concurrent data structure, this is
only a snapshot as viewed by this thread, and the result may change
if other threads are inserting values.
Sourcepub fn bytes(&self) -> usize
pub fn bytes(&self) -> usize
Returns the total number of bytes in this arena.
Note that because ArenaStr is a concurrent data structure, this is
only a snapshot as viewed by this thread, and the result may change
if other threads are inserting values.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if this arena is empty.
Note that because ArenaStr is a concurrent data structure, this is
only a snapshot as viewed by this thread, and the result may change
if other threads are inserting values.
Sourcepub fn find(&self, value: &str) -> Option<InternedStr>
pub fn find(&self, value: &str) -> Option<InternedStr>
Returns the given string’s InternedStr handle if it is already
interned.
Otherwise, this simply returns None without adding the string to
this arena.
Source§impl ArenaStr
impl ArenaStr
Sourcepub fn print_summary(&self, prefix: &str, title: &str, total_bytes: usize)
Available on crate feature debug only.
pub fn print_summary(&self, prefix: &str, title: &str, total_bytes: usize)
debug only.Prints a summary of the storage used by this arena to stdout.
Source§impl ArenaStr
impl ArenaStr
Sourcepub fn intern(&self, value: &str) -> InternedStr
pub fn intern(&self, value: &str) -> InternedStr
Interns the given value in this arena.
If the value was already interned in this arena, its interning index will simply be returned. Otherwise it will be stored into the arena.
Sourcepub fn lookup(&self, interned: InternedStr) -> &str
pub fn lookup(&self, interned: InternedStr) -> &str
Retrieves the given InternedStr value from this arena.
The caller is responsible for ensuring that the same arena was used to intern this value, otherwise an arbitrary value will be returned or a panic will happen.
If you only need to access the bytes,
lookup_bytes() may be more efficient.
Sourcepub fn lookup_bytes(&self, interned: InternedStr) -> &[u8] ⓘ
pub fn lookup_bytes(&self, interned: InternedStr) -> &[u8] ⓘ
Retrieves the bytes for the given InternedStr value from this arena.
The caller is responsible for ensuring that the same arena was used to intern this value, otherwise an arbitrary value will be returned or a panic will happen.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ArenaStr
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ArenaStr
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl GetSize for ArenaStr
Available on crate feature get-size2 only.
impl GetSize for ArenaStr
get-size2 only.Source§fn get_heap_size_with_tracker<Tr: GetSizeTracker>(
&self,
tracker: Tr,
) -> (usize, Tr)
fn get_heap_size_with_tracker<Tr: GetSizeTracker>( &self, tracker: Tr, ) -> (usize, Tr)
tracker. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreimpl Eq for ArenaStr
Auto Trait Implementations§
impl !Freeze for ArenaStr
impl !RefUnwindSafe for ArenaStr
impl Send for ArenaStr
impl Sync for ArenaStr
impl Unpin for ArenaStr
impl UnsafeUnpin for ArenaStr
impl UnwindSafe for ArenaStr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.