Struct exar::Connection [] [src]

pub struct Connection {
    // some fields omitted
}

Exar DB's database connection, which contains a reference to a collection wrapped into an Arc/Mutex. It allows publishing and subscribing to the underling collection of events.

Examples

extern crate exar;

use exar::*;
use std::sync::{Arc, Mutex};

let collection_name = "test";
let collection_config = CollectionConfig::default();
let collection = Collection::new(collection_name, &collection_config).unwrap();
let connection = Connection::new(Arc::new(Mutex::new(collection)));

Methods

impl Connection
[src]

fn new(collection: Arc<Mutex<Collection>>) -> Connection

Creates a new instance of a connection with the given collection.

fn publish(&self, event: Event) -> Result<u64DatabaseError>

Publishes an event into the underlying collection and returns the id for the event created or a DatabaseError if a failure occurs.

fn subscribe(&self, query: Query) -> Result<EventStreamDatabaseError>

Subscribes to the underlying collection of events using the given query and returns an event stream or a DatabaseError if a failure occurs.

fn close(self)

Closes the connection.

Trait Implementations

impl Debug for Connection
[src]

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

Formats the value using the given formatter.

impl Clone for Connection
[src]

fn clone(&self) -> Connection

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