[−][src]Struct indexer::Index
Fields
indexer: Indexer
Implementations
impl<'a> Index
[src]
pub fn new(indexer: Indexer) -> Self
[src]
Creates a new Index
Example
use indexer::{Indexer, IndexString, IndexOrd}; let string_indexer = Indexer::String(IndexString { ordering: IndexOrd::ASC });
pub fn insert(&mut self, k: String, v: Value)
[src]
Inserts a new entry or overrides a previous entry in the index
pub fn remove(&mut self, k: &String)
[src]
Removes an entry from the index
pub fn batch(&mut self, f: impl Fn(&mut Batch) + Sync + Send)
[src]
Batch transaction on the index. you can insert/update/delete multiple entries with one operation by commit the operation with b.commit()
Example
use indexer::{Index, BatchTransaction}; use serde_json::Value; let mut names_index = Index::new(string_indexer); names_index.batch(|b| { b.delete("user.4".to_owned()); b.insert("user.1".to_owned(), Value::String("Kwadwo".to_string())); b.insert("user.2".to_owned(), Value::String("Kwame".to_string())); b.update("user.3".to_owned(), Value::String("Joseph".to_string())); b.commit() });
pub fn iter(&self, f: impl Fn((&String, &Value)) + Sync + Send)
[src]
pub fn par_iter(&self, f: impl Fn((&String, &Value)) + Sync + Send)
[src]
pub fn find_all(&self, by: &str, cond: &str, eval: Value) -> Index
[src]
Query on an index. by using conditional operators
eq
Equalslt
Less thangt
Greater thanlike
Check for match using Glob style pattern matching
Example
let query = students_index.find_all("state", "eq", Value::String("CA".to_string())); println!("Find all students in CA: {:?}", query.read());
pub fn read(&self) -> &IndexMap<String, Value>
[src]
Trait Implementations
impl Clone for Index
[src]
impl<'de> Deserialize<'de> for Index
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Serialize for Index
[src]
Auto Trait Implementations
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnwindSafe for Index
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,