Struct exar::Database [] [src]

pub struct Database {
    // some fields omitted
}

Exar DB's main component, containing the database configuration and the references to the collections of events created. It is used to create new connections.

Examples

extern crate exar;

use exar::*;

let config = DatabaseConfig::default();
let mut db = Database::new(config);

let collection_name = "test";
let connection = db.connect(collection_name).unwrap();

Methods

impl Database
[src]

fn new(config: DatabaseConfig) -> Database

Creates a new instance of the database with the given configuration.

fn connect(&mut self, collection_name: &str) -> Result<ConnectionDatabaseError>

Returns a connection instance with the given name or a DatabaseError if a failure occurs.

fn get_collection(&mut self, collection_name: &str) -> Result<Arc<Mutex<Collection>>, DatabaseError>

Returns an existing collection instance with the given name wrapped into an Arc/Mutex or a DatabaseError if a failure occurs, it creates a new collection if it does not exist.

fn create_collection(&mut self, collection_name: &str) -> Result<Arc<Mutex<Collection>>, DatabaseError>

Creates and returns a new collection instance with the given name wrapped into an Arc/Mutex or a DatabaseError if a failure occurs.

fn drop_collection(&mut self, collection_name: &str) -> Result<()DatabaseError>

Drops the collection with the given name or returns an error if a failure occurs.

fn contains_collection(&self, collection_name: &str) -> bool

Returns wether a collection with the given name exists.

Trait Implementations

impl Debug for Database
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Clone for Database
[src]

fn clone(&self) -> Database

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more