Struct lasso::RodeoReader [−][src]
pub struct RodeoReader<K = Spur, S = RandomState> { /* fields omitted */ }
Expand description
A read-only view of a Rodeo
or ThreadedRodeo
that allows contention-free access to interned strings,
both key to string resolution and string to key lookups
The key and hasher types are the same as the Rodeo
or ThreadedRodeo
that created it, can be acquired with the
into_reader
methods.
Implementations
impl<K, S> RodeoReader<K, S>
[src]
impl<K, S> RodeoReader<K, S>
[src]pub fn get<T>(&self, val: T) -> Option<K> where
T: AsRef<str>,
S: BuildHasher,
K: Key,
[src]
pub fn get<T>(&self, val: T) -> Option<K> where
T: AsRef<str>,
S: BuildHasher,
K: Key,
[src]Get the key value of a string, returning None
if it doesn’t exist
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_reader(); assert_eq!(Some(key), rodeo.get("Strings of things with wings and dings")); assert_eq!(None, rodeo.get("This string isn't interned"));
pub fn contains<T>(&self, val: T) -> bool where
T: AsRef<str>,
S: BuildHasher,
K: Key,
[src]
pub fn contains<T>(&self, val: T) -> bool where
T: AsRef<str>,
S: BuildHasher,
K: Key,
[src]Returns true
if the given string has been interned
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_reader(); assert!(rodeo.contains("Strings of things with wings and dings")); assert!(!rodeo.contains("This string isn't interned"));
pub fn contains_key(&self, key: &K) -> bool where
K: Key,
[src]
pub fn contains_key(&self, key: &K) -> bool where
K: Key,
[src]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_reader(); assert!(rodeo.contains_key(&key)); assert!(!rodeo.contains_key(&key_that_doesnt_exist));
pub fn resolve<'a>(&'a self, key: &K) -> &'a str where
K: Key,
[src]
pub fn resolve<'a>(&'a self, key: &K) -> &'a str where
K: Key,
[src]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));
pub fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str> where
K: Key,
[src]
pub fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str> where
K: Key,
[src]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));
pub unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str where
K: Key,
[src]
pub unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str where
K: Key,
[src]Resolves a string by its key without bounds checks
Safety
The key must be valid for the current Reader
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)); }
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
[src]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_reader(); assert_eq!(rodeo.len(), 1);
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
[src]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_reader(); assert!(rodeo.is_empty());
pub fn iter(&self) -> Iter<'_, K>ⓘ
[src]
pub fn iter(&self) -> Iter<'_, K>ⓘ
[src]Returns an iterator over the interned strings and their key values
#[must_use]pub fn into_resolver(self) -> RodeoResolver<K>
[src]
#[must_use]pub fn into_resolver(self) -> RodeoResolver<K>
[src]Consumes the current rodeo and makes it into a RodeoResolver
, allowing
contention-free access from multiple threads with the lowest possible memory consumption
Example
use lasso::Rodeo; // ThreadedRodeo is interchangeable for Rodeo here let mut rodeo = Rodeo::default(); let key = rodeo.get_or_intern("Appear weak when you are strong, and strong when you are weak."); let reader_rodeo = rodeo.into_reader(); let resolver_rodeo = reader_rodeo.into_resolver(); assert_eq!( "Appear weak when you are strong, and strong when you are weak.", resolver_rodeo.resolve(&key), );
Trait Implementations
impl<K: Debug, S: Debug> Debug for RodeoReader<K, S>
[src]
impl<K: Debug, S: Debug> Debug for RodeoReader<K, S>
[src]impl<'de, K: Key, S: BuildHasher + Default> Deserialize<'de> for RodeoReader<K, S>
[src]
impl<'de, K: Key, S: BuildHasher + Default> Deserialize<'de> for RodeoReader<K, S>
[src]fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
impl<K, S> Index<K> for RodeoReader<K, S> where
K: Key,
S: BuildHasher,
[src]
impl<K, S> Index<K> for RodeoReader<K, S> where
K: Key,
S: BuildHasher,
[src]impl<'a, K: Key, S> IntoIterator for &'a RodeoReader<K, S>
[src]
impl<'a, K: Key, S> IntoIterator for &'a RodeoReader<K, S>
[src]impl<K, S> IntoResolver<K> for RodeoReader<K, S> where
K: Key,
S: BuildHasher,
[src]
impl<K, S> IntoResolver<K> for RodeoReader<K, S> where
K: Key,
S: BuildHasher,
[src]type Resolver = RodeoResolver<K>
type Resolver = RodeoResolver<K>
The type of Resolver
the reader will be converted into
#[must_use]fn into_resolver(self) -> Self::Resolver where
Self: 'static,
[src]
#[must_use]fn into_resolver(self) -> Self::Resolver where
Self: 'static,
[src]#[must_use]fn into_resolver_boxed(self: Box<Self>) -> Self::Resolver where
Self: 'static,
[src]
Self: 'static,
impl<K, S> PartialEq<Rodeo<K, S>> for RodeoReader<K, S>
[src]
impl<K, S> PartialEq<Rodeo<K, S>> for RodeoReader<K, S>
[src]impl<K, S> PartialEq<RodeoReader<K, S>> for RodeoReader<K, S>
[src]
impl<K, S> PartialEq<RodeoReader<K, S>> for RodeoReader<K, S>
[src]impl<K, S> PartialEq<RodeoReader<K, S>> for RodeoResolver<K>
[src]
impl<K, S> PartialEq<RodeoReader<K, S>> for RodeoResolver<K>
[src]impl<K, S> PartialEq<RodeoReader<K, S>> for Rodeo<K, S>
[src]
impl<K, S> PartialEq<RodeoReader<K, S>> for Rodeo<K, S>
[src]impl<K, S> PartialEq<RodeoReader<K, S>> for ThreadedRodeo<K, S> where
K: Eq + Hash + Key,
S: Clone + BuildHasher,
[src]
impl<K, S> PartialEq<RodeoReader<K, S>> for ThreadedRodeo<K, S> where
K: Eq + Hash + Key,
S: Clone + BuildHasher,
[src]impl<K, S> PartialEq<RodeoResolver<K>> for RodeoReader<K, S>
[src]
impl<K, S> PartialEq<RodeoResolver<K>> for RodeoReader<K, S>
[src]impl<K, S> Reader<K> for RodeoReader<K, S> where
K: Key,
S: BuildHasher,
[src]
impl<K, S> Reader<K> for RodeoReader<K, S> where
K: Key,
S: BuildHasher,
[src]impl<K, S> Resolver<K> for RodeoReader<K, S> where
K: Key,
[src]
impl<K, S> Resolver<K> for RodeoReader<K, S> where
K: Key,
[src]fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>
[src]
fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>
[src]Attempts to resolve the given key into a string, returning None
if it cannot be found Read more
unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str
[src]
unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str
[src]Resolves a string by its key without preforming bounds checks Read more
fn contains_key(&self, key: &K) -> bool
[src]
fn contains_key(&self, key: &K) -> bool
[src]Returns true
if the current interner contains the given key
impl<K, H> Serialize for RodeoReader<K, H>
[src]
impl<K, H> Serialize for RodeoReader<K, H>
[src]impl<K, S> Eq for RodeoReader<K, S>
[src]
impl<K: Send, S: Send> Send for RodeoReader<K, S>
[src]
impl<K: Sync, S: Sync> Sync for RodeoReader<K, S>
[src]
Auto Trait Implementations
impl<K, S> RefUnwindSafe for RodeoReader<K, S> where
K: RefUnwindSafe,
S: RefUnwindSafe,
K: RefUnwindSafe,
S: RefUnwindSafe,
impl<K, S> Unpin for RodeoReader<K, S> where
K: Unpin,
S: Unpin,
K: Unpin,
S: Unpin,
impl<K, S> UnwindSafe for RodeoReader<K, S> where
K: UnwindSafe,
S: UnwindSafe,
K: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,