RethinkDB Driver

This is a [RethinkDB] driver written in [Rust].

Build Status Latest Version Docs

Example

```rust extern crate futures; extern crate tokiocore; extern crate reql; extern crate reqltypes;

use futures::stream::Stream; use tokiocore::reactor::Core; use reql::{Client, Run, Document}; use reqltypes::ServerStatus;

fn main() { // Create a new ReQL client let r = Client::new();

// Create an even loop
let core = Core::new().unwrap();

// Create a connection pool
let conn = r.connect(&core.handle()).unwrap();

// Run the query
let query = r.db("rethinkdb").table("server_status").run::<ServerStatus>(conn).unwrap();

// Process the results
let stati = query.and_then(|status| {
    match status {
        // The server returned the response we were expecting
        Some(Document::Expected(status)) => {
            println!("{:?}", status);
        }
        // We got a response alright, but it wasn't the one were expecting
        // plus it's not an error either, otherwise it would have been
        // returned as such (This simply means that the response we got
        // couldn't be serialised into the type we were expecting)
        Some(Document::Unexpected(status)) => {
            println!("unexpected response from server: {:?}", status);
        }
        // This is impossible in this particular example since there
        // needs to be at least one server available to give this
        // response otherwise we would have run into an error for
        // failing to connect
        None => {
            println!("got no documents in the database");
        }
    }
    Ok(())
})
// Our query ran into an error
.or_else(|error| {
    println!("{:?}", error);
    Err(())
})
;

// Wait for all the results to be processed
for _ in stati.wait() { }

} ```

Check out the [blocking example] to see this same example implemented using a for loop instead.

License

Licensed under either of * Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) * MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.