Struct exar::Collection
[−]
[src]
pub struct Collection { // some fields omitted }
Exar DB's collection of events, containing the reference to the log and index files.
It is responsible of creating and managing the log scanner threads and the single-threaded logger. It allows publishing and subscribing to the underling events log.
Examples
extern crate exar; use exar::*; let collection_name = "test"; let collection_config = CollectionConfig::default(); let collection = Collection::new(collection_name, &collection_config).unwrap();
Methods
impl Collection
[src]
fn new(collection_name: &str, config: &CollectionConfig) -> Result<Collection, DatabaseError>
Creates a new instance of a collection with the given name and configuration
or a DatabaseError
if a failure occurs.
fn publish(&mut self, event: Event) -> Result<u64, DatabaseError>
Publishes an event into the collection and returns the id
for the event created
or a DatabaseError
if a failure occurs.
fn subscribe(&mut self, query: Query) -> Result<EventStream, DatabaseError>
Subscribes to the collection of events using the given query and returns an event stream
or a DatabaseError
if a failure occurs.
fn drop(&mut self) -> Result<(), DatabaseError>
Drops the collection, kills the scanner threads and remove the log and index files.