adamhjk / couchbase-rs

The official Couchbase Rust SDK

Home Page:https://couchbase.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Couchbase Rust SDK

LICENSE Crates.io Version

This is the repository for the official, community supported Couchbase Rust SDK. It is currently a work in progress and built on top of libcouchbase.

Requirements

Make sure to have all libcouchbase requirements satisfied to build it properly. Also bindgen requirements need to be in place. Other than that, you should be good to go out of the box if you use a recent rust version. We recommend the 2018 edition just because.

Installation

[dependencies]
couchbase = "1.0.0-alpha.2"

Usage

The examples folder has a bunch more, but here is a basic getting started doing a kv op:

use couchbase::Cluster;
use futures::Future;
use serde_derive::Deserialize;

#[derive(Debug, Deserialize)]
struct Airport {
    airportname: String,
    icao: String,
}

fn main() {
    let mut cluster = Cluster::connect("couchbase://127.0.0.1", "Administrator", "password")
        .expect("Could not create Cluster reference!");

    let bucket = cluster
        .bucket("travel-sample")
        .expect("Could not open bucket");
    let collection = bucket.default_collection();

    let found_doc = collection
        .get("airport_1297", None)
        .wait()
        .expect("Error while loading doc");
    println!("Airline Document: {:?}", found_doc);

    if found_doc.is_some() {
        println!(
            "Content Decoded {:?}",
            found_doc.unwrap().content_as::<Airport>()
        );
    }

    cluster.disconnect().expect("Could not shutdown properly");
}

Examples

More examples can be found in the examples folder. Please open a ticket if something is not present or does not showcase what you need.

About

The official Couchbase Rust SDK

https://couchbase.com

License:Apache License 2.0


Languages

Language:C 48.8%Language:C++ 43.9%Language:Rust 3.3%Language:Roff 1.5%Language:CMake 1.4%Language:CSS 0.3%Language:JavaScript 0.2%Language:Objective-C 0.1%Language:Makefile 0.1%Language:Ruby 0.1%Language:Perl 0.1%Language:HTML 0.0%Language:Shell 0.0%Language:Batchfile 0.0%