[−][src]Trait string_interner::backend::Backend
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
pub fn with_capacity(cap: usize) -> Self
[src]
Creates a new backend for the given capacity.
The capacity denotes how many strings are expected to be interned.
pub fn intern(&mut self, string: &str) -> S
[src]
Interns the given string and returns its interned ref and symbol.
Note
The backend must make sure that the returned symbol maps back to the
original string in its resolve
method.
pub fn resolve(&self, symbol: S) -> Option<&str>
[src]
Resolves the given symbol to its original string contents.
pub unsafe fn resolve_unchecked(&self, symbol: S) -> &str
[src]
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.
Provided methods
pub fn intern_static(&mut self, string: &'static str) -> S
[src]
Implementors
impl<S> Backend<S> for BucketBackend<S> where
S: Symbol,
[src]
S: Symbol,
pub fn with_capacity(cap: usize) -> Self
[src]
pub fn intern(&mut self, string: &str) -> S
[src]
pub fn intern_static(&mut self, string: &'static str) -> S
[src]
pub fn resolve(&self, symbol: S) -> Option<&str>
[src]
pub unsafe fn resolve_unchecked(&self, symbol: S) -> &str
[src]
impl<S> Backend<S> for SimpleBackend<S> where
S: Symbol,
[src]
S: Symbol,
pub fn with_capacity(cap: usize) -> Self
[src]
pub fn intern(&mut self, string: &str) -> S
[src]
pub fn resolve(&self, symbol: S) -> Option<&str>
[src]
pub unsafe fn resolve_unchecked(&self, symbol: S) -> &str
[src]
impl<S> Backend<S> for StringBackend<S> where
S: Symbol,
[src]
S: Symbol,