extern crate couchbase;
extern crate futures;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
use couchbase::Cluster;
use futures::Future;
use couchbase::document::{Document, JsonDocument};
#[derive(Serialize, Deserialize, Debug)]
struct Airline {
id: u32,
#[serde(rename = "type")] _type: String,
name: String,
iata: String,
icao: String,
callsign: String,
country: String,
}
fn main() {
let mut cluster = Cluster::new("localhost").expect("Could not initialize Cluster");
cluster.authenticate("Administrator", "password");
let bucket = cluster
.open_bucket("travel-sample", None)
.expect("Could not open Bucket");
let document: Airline = bucket
.get::<JsonDocument<_>, _>("airline_10123")
.map(|doc| doc.content().unwrap())
.wait()
.expect("Document not found!");
println!("{:?}", document);
}