[][src]Struct ejdb::Index

pub struct Index<'coll, 'db: 'coll> { /* fields omitted */ }

A builder for an operation on an index of a certain field of an EJDB collection.

In EJDB every collection can have an index on the fields of its records. Indices can be of one of three types:

Indices can be set, dropped, optimized or rebuilt. Indices are stored in a separate file from their collections and can speed up certain access patterns in queries. Naturally, indices are specified for some field in collection records, so this structure is used to configure indices for one specific field.

Index manipulation is done with this structure which provides a builder-like interface to create, change properties or drop an index on one field. Since an index can't exist separately from a collection, this structure is linked via a lifetime to its corresponding collection object. An instance of this structure is obtained with Collection::index() method.

Example

let db = Database::open("/path/to/db").unwrap();
let coll = db.collection("some_collection").unwrap();

// create a string index on `name` field
coll.index("name").string(true).set().unwrap();

// create multiple indices on `coords` field
coll.index("coords").number().array().set().unwrap();

Methods

impl<'coll, 'db: 'coll> Index<'coll, 'db>[src]

pub fn string(self, case_sensitive: bool) -> Self[src]

Specifies that this index must be built over string values of this field.

case_sensitive argument determines whether this index must take string case into account, true for case sensitive matching, false for the opposite.

pub fn number(self) -> Self[src]

Specifies that this index must be built over numeric values of this field.

pub fn array(self) -> Self[src]

Specifies that this index must be built over array values of this field.

pub fn set(self) -> Result<()>[src]

Creates one or more indices of specified types on this field.

Panics if no types were specified before calling this method.

pub fn drop_all(self) -> Result<()>[src]

Drops all indices on this field.

pub fn drop(self) -> Result<()>[src]

Drops indices of the previously specified types on this field.

Panics if no type has been set prior to calling this method.

pub fn rebuild(self) -> Result<()>[src]

Rebuilds indices of the previously specified types on this field from scratch.

Panics if no type has been set prior to calling this method.

pub fn optimize(self) -> Result<()>[src]

Optimizes indices of the previously specified types on this field.

Panics if no type has been set prior to calling this method.

Auto Trait Implementations

impl<'coll, 'db> !Send for Index<'coll, 'db>

impl<'coll, 'db> !Sync for Index<'coll, 'db>

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

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