Struct lasso::RodeoReader

source ·
pub struct RodeoReader<K = Spur, S = RandomState> { /* private fields */ }
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§

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"));

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"));

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));

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));

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));

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));
}

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);

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());

Returns an iterator over the interned strings and their key values

Returns an iterator over the interned strings

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§

Formats the value using the given formatter. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of Resolver the reader will be converted into
Consumes the current Reader and makes it into a Resolver, allowing contention-free access from multiple threads with the lowest possible memory consumption
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Get a key for the given string value if it exists
Returns true if the current interner contains the given string
Resolves the given key into a string Read more
Attempts to resolve the given key into a string, returning None if it cannot be found
Resolves a string by its key without preforming bounds checks Read more
Returns true if the current interner contains the given key
Gets the number of currently interned strings
Returns true if there are no currently interned strings

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.