[−][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
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.
unsafe fn intern(&mut self, string: &str) -> (InternedStr, S)
Interns the given string and returns its interned ref and symbol.
Safety
The returned InternedStr
points to an actually interned string. The
backend must make sure that it never moves its interned string arounds.
This is why this method is unsafe
.
fn resolve(&self, symbol: S) -> Option<&str>
Resolves the given symbol to its original string contents.
Provided methods
unsafe fn intern_static(&mut self, string: &'static str) -> (InternedStr, S)
Interns the given static string and returns its interned ref and symbol.
Safety
The returned InternedStr
should point to the static string itself.
Backends should try to not allocate any interned strings in this case.
Implementors
impl<S> Backend<S> for BucketBackend<S> where
S: Symbol,
[src]
S: Symbol,
fn with_capacity(cap: usize) -> Self
[src]
unsafe fn intern(&mut self, string: &str) -> (InternedStr, S)
[src]
unsafe fn intern_static(&mut self, string: &'static str) -> (InternedStr, S)
[src]
fn resolve(&self, symbol: S) -> Option<&str>
[src]
impl<S> Backend<S> for SimpleBackend<S> where
S: Symbol,
[src]
S: Symbol,