Skip to content

Commit

Permalink
Add examples to crate root docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed Mar 30, 2016
1 parent 88f697a commit e4e474a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,3 @@ version = "0.7.0"
[features]
default = ["serde_codegen"]
nightly = ["serde_macros"]

[lib]
doctest = false
name = "etcd"
52 changes: 52 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,61 @@
//! `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:
//!
//! ```no_run
//! 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:
//!
//! ```no_run
//! 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());
//! }
//! ```

#![cfg_attr(feature = "serde_macros", feature(custom_derive, plugin))]
#![cfg_attr(feature = "serde_macros", plugin(serde_macros))]
#![deny(missing_docs)]

extern crate hyper;
extern crate openssl;
Expand Down
1 change: 1 addition & 0 deletions src/stats_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct SelfStats {
pub id: String,
/// The member's name.
pub name: String,
/// A small amount of information about the leader of the cluster.
#[serde(rename="leaderInfo")]
pub leader_info: LeaderInfo,
/// The number of received requests.
Expand Down

0 comments on commit e4e474a

Please sign in to comment.