Skip to main content

Resolver

Trait Resolver 

Source
pub trait Resolver<K = Spur> {
    // Required methods
    fn resolve<'a>(&'a self, key: &K) -> &'a str;
    fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>;
    unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str;
    fn contains_key(&self, key: &K) -> bool;
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A generic interface that allows using any underlying interner only for its resolution capabilities, allowing only key -> str lookups

Required Methods§

Source

fn resolve<'a>(&'a self, key: &K) -> &'a str

Resolves the given key into a string

§Panics

Panics if the key is not contained in the current Resolver

Source

fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>

Attempts to resolve the given key into a string, returning None if it cannot be found

Source

unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str

Resolves a string by its key without preforming bounds checks

§Safety

The key must be valid for the current Resolver

Source

fn contains_key(&self, key: &K) -> bool

Returns true if the current interner contains the given key

Source

fn len(&self) -> usize

Gets the number of currently interned strings

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if there are no currently interned strings

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<K, I> Resolver<K> for Box<I>
where K: Key, I: Resolver<K> + ?Sized + 'static,

Source§

fn resolve<'a>(&'a self, key: &K) -> &'a str

Source§

fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>

Source§

unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str

Source§

fn contains_key(&self, key: &K) -> bool

Source§

fn len(&self) -> usize

Source§

impl<T, K> Resolver<K> for &T
where T: Resolver<K>,

Source§

fn resolve<'a>(&'a self, key: &K) -> &'a str

Source§

fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>

Source§

unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str

Source§

fn contains_key(&self, key: &K) -> bool

Source§

fn len(&self) -> usize

Source§

impl<T, K> Resolver<K> for &mut T
where T: Resolver<K>,

Source§

fn resolve<'a>(&'a self, key: &K) -> &'a str

Source§

fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>

Source§

unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str

Source§

fn contains_key(&self, key: &K) -> bool

Source§

fn len(&self) -> usize

Implementors§

Source§

impl<K, S> Resolver<K> for Rodeo<K, S>
where K: Key,

Source§

impl<K, S> Resolver<K> for RodeoReader<K, S>
where K: Key,

Source§

impl<K, S> Resolver<K> for ThreadedRodeo<K, S>
where K: Key + Hash, S: BuildHasher + Clone,

Available on crate feature multi-threaded only.
Source§

impl<K> Resolver<K> for RodeoResolver<K>
where K: Key,