Crate etcd (0.5.0) [] [src]

Crate etcd provides a client for etcd, a distributed key-value store from CoreOS.

Client is the entry point for all API calls. Types for etcd's primary key space operations are reexported to the crate root. Types for other etcd operations are found in the crate's public modules.

Examples

Basic usage:

extern crate etcd;

use std::default::Default;

use etcd::Client;

fn main() {
    // Creates a client that will make API calls to http://127.0.0.1:2379.
    let client = Client::default();

    assert!(client.set("/foo", "bar", None).is_ok());

    let value = client.get("/foo", false, false, false)
                      .ok().unwrap().node.unwrap().value.unwrap();

    assert_eq!(value, "bar".to_owned());
}

Using HTTPS with client certificate authentication and a username and password for HTTP Basic Authorization:

extern crate etcd;

use etcd::{Client, ClientOptions};

fn main() {
    let client = Client::with_options(&["https://example.com:2379"], ClientOptions {
        ca: Some("/path/to/ca_cert.pem".to_owned()),
        cert_and_key: Some((
            "/path/to/client_cert.pem".to_owned(),
            "/path/to/client_key.pem".to_owned(),
        )),
        username_and_password: Some(("jimmy".to_owned(), "secret".to_owned())),
    }).unwrap();

    assert!(client.set("/foo", "bar", None).is_ok());

    let value = client.get("/foo", false, false, false)
                      .ok().unwrap().node.unwrap().value.unwrap();

    assert_eq!(value, "bar".to_owned());
}

Modules

stats

Types for statistics operations.

version

Types for the version endpoint.

Structs

ApiError

An error returned by etcd.

Client

API client for etcd. All API calls are made via the client.

ClientOptions

Options for configuring the behavior of a Client.

KeySpaceInfo

Information about the result of a successful key space operation.

Node

An etcd key-value pair or directory.

Enums

Error

An error returned by Client method failures.

Type Definitions

EtcdResult

A generic result type returned by non-key space Client methods.

KeySpaceResult

The result type returned by all key space API calls.