pub struct SQLiteSet { /* private fields */ }Expand description
A hash set with string keys, backed by an SQLite in-memory database.
By default, SQLiteSet treats its keys as case-sensitive, but a case-insensitive variant is available. Even when using the case-sensitive set variant, for some operations a dedicated “case-insensitive” version is provided.
Important: For bulk inserts or updates, it is strongly recommended to use an explicit transaction. Without one, SQLite executes each insert or update in its own transaction, which can significantly degrade performance.
Implementations§
Source§impl SQLiteSet
impl SQLiteSet
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Creates a new, empty SQLite-backed hash set with case-sensitive keys.
Sourcepub fn with_nocase() -> Result<Self, Error>
pub fn with_nocase() -> Result<Self, Error>
Creates a new, empty SQLite-backed hash set with case-insensitive keys.
Sourcepub fn transaction(&mut self) -> Result<SQLiteSetTransaction<'_>, Error>
pub fn transaction(&mut self) -> Result<SQLiteSetTransaction<'_>, Error>
Starts a new SQLite transaction for this set.
Please note that using an explicit SQLite transaction allows for much more efficient bulk inserts 🚀
Returns the new SQLiteSetTransaction instance.
Sourcepub fn insert(&mut self, key: &str) -> Result<bool, Error>
pub fn insert(&mut self, key: &str) -> Result<bool, Error>
Inserts the given key into the set.
Returns true, if the set did not already contain the key; otherwise returns false.
Sourcepub fn contains(&self, key: &str) -> Result<bool, Error>
pub fn contains(&self, key: &str) -> Result<bool, Error>
Checks whether the set contains the specified key.
For case-sensitive sets, the check is case-sensitive; for case-insensitive sets, the check is case-insensitive.
Returns true, if the set contains the key; otherwise returns false.
Sourcepub fn contains_nocase(&self, key: &str) -> Result<bool, Error>
pub fn contains_nocase(&self, key: &str) -> Result<bool, Error>
This is the “case-insensitive” version of the contains() function.
The check is always performed case-insensitive.
Returns true, if the set contains the key; otherwise returns false.
Sourcepub fn remove(&mut self, key: &str) -> Result<bool, Error>
pub fn remove(&mut self, key: &str) -> Result<bool, Error>
Removes the specified key from the set, if present.
For case-sensitive sets, the key is treated as case-sensitive; for case-insensitive sets, it is treated as case-insensitive.
Returns true, if the set contained the key; otherwise returns false.
Sourcepub fn remove_nocase(&mut self, key: &str) -> Result<bool, Error>
pub fn remove_nocase(&mut self, key: &str) -> Result<bool, Error>
This is the “case-insensitive” version of the remove() function.
The key is always treated as case-insensitive.
Returns true, if the set contained the key; otherwise returns false.
Sourcepub fn for_each<F>(&self, callback: F) -> Result<(), Error>
pub fn for_each<F>(&self, callback: F) -> Result<(), Error>
Invokes the given callback function for each key that is currently contained in the set.
This function does not guarantee a specific iteration order.
Sourcepub fn find<P>(&self, predicate: P) -> Result<Option<String>, Error>
pub fn find<P>(&self, predicate: P) -> Result<Option<String>, Error>
Searches the set for the first key that satisfies the given predicate.
Returns the first key that satisfies the given predicate, or None if no key satisfies the predicate or the set is empty.
This function does not guarantee a specific iteration order.
Also, the predicate is not always tested on all keys, because the function returns at the first match.