Skip to content

adamhjk/couchbase-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 49.0%
  • C++ 43.9%
  • Rust 3.3%
  • Roff 1.5%
  • CMake 1.4%
  • CSS 0.3%
  • Other 0.6%