simplist/
lib.rs

1//! # simplist: plain and simple http.
2//!
3//! a plain and simple http library for when you just want to make a darn request!
4//!
5//! this crate is a super thin and lightweight wrapper on top of hyper, and provides apis for futures-based async,
6//! traditional sync and async-await models.
7//!
8//! [`HttpClient`](struct.HttpClient.html) is the primary interface for making http requests.
9//!
10//! # features.
11//!
12//! - `nightly`: when turned on, simplist will perform about one allocation per request by using `impl Future`, which is
13//!   currently an experimental feature. when compiling for the stable compiler, simplist needs to box some future types
14//!   because they cannot be named.
15//! - `scramble`: when turned on, simplist will compile out most error messages, replacing them with an empty string.
16//!
17//! if you're using a nightly compiler, turn on the nightly feature in your `cargo.toml`!
18//!
19//! ```
20//! simplist = { version = "0.0.5", features = ["nightly"] }
21//! ```
22//!
23//! # examples.
24//!
25//! ## asynchronous, with await notation.
26//!
27//! ```
28//! use simplist::HttpClient;
29//!
30//! let http = HttpClient::new(handle);
31//! let html = await http.get_string("https://hinaria.com")?;
32//!
33//! println!("{:?}", html);
34//! // => "<!doctype html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\"> ..."
35//! ```
36//!
37//! ## asynchronous, with future callbacks.
38//!
39//! ```
40//! use simplist::HttpClient;
41//!
42//! let http   = HttpClient::new(handle);
43//! let future = http.get_string("https://hinaria.com").and_then(|html| {
44//!     println!("{:?}", html);
45//!     Ok(())
46//! }).map_err(|_| ());
47//!
48//! handle.spawn(future);
49//! // => "<!doctype html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\"> ..."
50//! ```
51//!
52//! ## synchronous.
53//!
54//! ```
55//! use simplist::HttpSyncClient;
56//!
57//! let http = HttpSyncClient::new(handle);
58//! let html = http.get_string("https://hinaria.com")?;
59//!
60//! println!("{:?}", html);
61//! // => "<!doctype html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\"> ..."
62//! ```
63
64
65
66#![cfg_attr(feature = "nightly", feature(conservative_impl_trait))]
67
68extern crate bytes;
69extern crate futures;
70extern crate hyper;
71extern crate tokio_core;
72
73
74
75#[macro_use]
76mod hina;
77
78
79
80#[cfg(    feature = "nightly") ] #[path = "simplist/mod.rs"]        mod simplist;
81#[cfg(not(feature = "nightly"))] #[path = "simplist-stable/mod.rs"] mod simplist;
82
83pub use self::simplist::*;