[][src]Struct indexer::Index

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

Fields

indexer: Indexer

Implementations

impl Index[src]

pub fn from(v: &[u8]) -> Result<Self, ()>[src]

pub fn to_vec(&self) -> Vec<u8>[src]

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<V>(&mut self, key: &str, value: V) where
    V: Serialize + Deserialize<'a>, 
[src]

Inserts a new entry or overrides a previous entry in the index

pub fn remove(&mut self, k: &str)[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");
    b.insert("user.1", "Kwadwo".to_string());
    b.insert("user.2", Value::String("Kwame".to_string()));
    b.update("user.3", Value::String("Joseph".to_string()));
    b.commit()
});

pub fn get_all_items(&self, f: impl Fn((&String, &Value)) + Sync + Send)[src]

pub fn par_get_all_items(&self, f: impl Fn((&String, &Value)) + Sync + Send)[src]

pub fn find_where<V>(&self, field: &str, op: Op, value: V) -> QueryResult where
    V: Serialize + Deserialize<'a>, 
[src]

Query on an index. by using conditional operators

  • eq Equals
  • lt Less than
  • gt Greater than
  • like Check for match using Glob style pattern matching

Example

 let query = students_index.find_where("state", Op::EQ, "CA");
 println!("Find all students in CA: {:?}", query());

pub fn count(&self) -> usize[src]

👎 Deprecated since 0.2.5:

Please use the size() instead

pub fn size(&self) -> usize[src]

pub fn get_items(&self) -> Vec<(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> Pointable for T

type Init = T

The type for initializers.

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.