[][src]Struct indexer::Index

pub struct Index {
    pub indexer: Indexer,
    // some fields omitted
}

Fields

indexer: Indexer

Implementations

impl 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 read(&self) -> &IndexMap<String, Value>[src]

Trait Implementations

impl Clone for Index[src]

impl<'de> Deserialize<'de> for Index[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.