Struct lasso::RodeoResolver

source ·
pub struct RodeoResolver<K = Spur> { /* private fields */ }
Expand description

A read-only view of a Rodeo or ThreadedRodeo that allows contention-free access to interned strings with only key to string resolution

The key type is the same as the Rodeo or ThreadedRodeo that created it

Implementations§

source§

impl<K> RodeoResolver<K>

source

pub fn resolve<'a>(&'a self, key: &K) -> &'a strwhere K: Key,

Resolves a string by its key. Only keys made by the current Resolver or the creator of the current Resolver may be used

Panics

Panics if the key is out of bounds

Example
use lasso::Rodeo;

// ThreadedRodeo is interchangeable for Rodeo here
let mut rodeo = Rodeo::default();
let key = rodeo.get_or_intern("Strings of things with wings and dings");

let rodeo = rodeo.into_resolver();
assert_eq!("Strings of things with wings and dings", rodeo.resolve(&key));
source

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

Resolves a string by its key, returning None if the key is out of bounds. Only keys made by the current Resolver or the creator of the current Resolver may be used

Example
use lasso::Rodeo;

// ThreadedRodeo is interchangeable for Rodeo here
let mut rodeo = Rodeo::default();
let key = rodeo.get_or_intern("Strings of things with wings and dings");

let rodeo = rodeo.into_resolver();
assert_eq!(Some("Strings of things with wings and dings"), rodeo.try_resolve(&key));
source

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

Resolves a string by its key without preforming bounds checks

Safety

The key must be valid for the current interner

Example
use lasso::Rodeo;

// ThreadedRodeo is interchangeable for Rodeo here
let mut rodeo = Rodeo::default();
let key = rodeo.get_or_intern("Strings of things with wings and dings");

let rodeo = rodeo.into_resolver();
unsafe {
    assert_eq!("Strings of things with wings and dings", rodeo.resolve_unchecked(&key));
}
source

pub fn contains_key(&self, key: &K) -> boolwhere K: Key,

Returns true if the given key exists in the current interner

Example
use lasso::Rodeo;

let mut rodeo = Rodeo::default();
let key = rodeo.get_or_intern("Strings of things with wings and dings");

let rodeo = rodeo.into_resolver();
assert!(rodeo.contains_key(&key));
assert!(!rodeo.contains_key(&key_that_doesnt_exist));
source

pub fn len(&self) -> usize

Gets the number of interned strings

Example
use lasso::Rodeo;

// ThreadedRodeo is interchangeable for Rodeo here
let mut rodeo = Rodeo::default();
rodeo.get_or_intern("Documentation often has little hidden bits in it");

let rodeo = rodeo.into_resolver();
assert_eq!(rodeo.len(), 1);
source

pub fn is_empty(&self) -> bool

Returns true if there are no currently interned strings

Example
use lasso::Rodeo;

// ThreadedRodeo is interchangeable for Rodeo here
let rodeo = Rodeo::default();

let rodeo = rodeo.into_resolver();
assert!(rodeo.is_empty());
source

pub fn iter(&self) -> Iter<'_, K>

Returns an iterator over the interned strings and their key values

source

pub fn strings(&self) -> Strings<'_, K>

Returns an iterator over the interned strings

Trait Implementations§

source§

impl<K: Debug> Debug for RodeoResolver<K>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, K: Key> Deserialize<'de> for RodeoResolver<K>

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<K: Key> Index<K> for RodeoResolver<K>

§

type Output = str

The returned type after indexing.
source§

fn index(&self, idx: K) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<'a, K: Key> IntoIterator for &'a RodeoResolver<K>

§

type Item = (K, &'a str)

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, K>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<K, S> PartialEq<Rodeo<K, S>> for RodeoResolver<K>

source§

fn eq(&self, other: &Rodeo<K, S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, S> PartialEq<RodeoReader<K, S>> for RodeoResolver<K>

source§

fn eq(&self, other: &RodeoReader<K, S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, S> PartialEq<RodeoResolver<K>> for Rodeo<K, S>

source§

fn eq(&self, other: &RodeoResolver<K>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, S> PartialEq<RodeoResolver<K>> for RodeoReader<K, S>

source§

fn eq(&self, other: &RodeoResolver<K>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K> PartialEq<RodeoResolver<K>> for RodeoResolver<K>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, S> PartialEq<RodeoResolver<K>> for ThreadedRodeo<K, S>where K: Eq + Hash + Key, S: Clone + BuildHasher,

source§

fn eq(&self, other: &RodeoResolver<K>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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

source§

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

Resolves the given key into a string Read more
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 Read more
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
source§

fn is_empty(&self) -> bool

Returns true if there are no currently interned strings
source§

impl<K> Serialize for RodeoResolver<K>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<K> Eq for RodeoResolver<K>

source§

impl<K: Send> Send for RodeoResolver<K>

source§

impl<K: Sync> Sync for RodeoResolver<K>

Auto Trait Implementations§

§

impl<K> RefUnwindSafe for RodeoResolver<K>where K: RefUnwindSafe,

§

impl<K> Unpin for RodeoResolver<K>where K: Unpin,

§

impl<K> UnwindSafe for RodeoResolver<K>where K: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

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

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,