Trait string_interner::backend::Backend [−][src]
pub trait Backend<S>: Default where
S: Symbol, {
fn with_capacity(cap: usize) -> Self;
fn intern(&mut self, string: &str) -> S;
fn shrink_to_fit(&mut self);
fn resolve(&self, symbol: S) -> Option<&str>;
unsafe fn resolve_unchecked(&self, symbol: S) -> &str;
fn intern_static(&mut self, string: &'static str) -> S { ... }
}
Expand description
Types implementing this trait may act as backends for the string interner.
The job of a backend is to actually store, manage and organize the interned strings. Different backends have different trade-offs. Users should pick their backend with hinsight of their personal use-case.
Required methods
fn with_capacity(cap: usize) -> Self
fn with_capacity(cap: usize) -> Self
Creates a new backend for the given capacity.
The capacity denotes how many strings are expected to be interned.
fn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
Shrink backend capacity to fit interned symbols exactly.
Resolves the given symbol to its original string contents.
unsafe fn resolve_unchecked(&self, symbol: S) -> &str
unsafe fn resolve_unchecked(&self, symbol: S) -> &str
Resolves the given symbol to its original string contents.
Safety
Does not perform validity checks on the given symbol and relies
on the caller to be provided with a symbol that has been generated
by the intern
or
intern_static
methods of the same
interner backend.