Expand description
§simplist: plain and simple http.
a plain and simple http library for when you just want to make a darn request!
this crate is a super thin and lightweight wrapper on top of hyper, and provides apis for futures-based async, traditional sync and async-await models.
HttpClient is the primary interface for making http requests.
§features.
nightly: when turned on, simplist will perform about one allocation per request by usingimpl Future, which is currently an experimental feature. when compiling for the stable compiler, simplist needs to box some future types because they cannot be named.scramble: when turned on, simplist will compile out most error messages, replacing them with an empty string.
if you’re using a nightly compiler, turn on the nightly feature in your cargo.toml!
simplist = { version = "0.0.5", features = ["nightly"] }§examples.
§asynchronous, with await notation.
use simplist::HttpClient;
let http = HttpClient::new(handle);
let html = await http.get_string("https://hinaria.com")?;
println!("{:?}", html);
// => "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\"> ..."§asynchronous, with future callbacks.
use simplist::HttpClient;
let http = HttpClient::new(handle);
let future = http.get_string("https://hinaria.com").and_then(|html| {
println!("{:?}", html);
Ok(())
}).map_err(|_| ());
handle.spawn(future);
// => "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\"> ..."§synchronous.
use simplist::HttpSyncClient;
let http = HttpSyncClient::new(handle);
let html = http.get_string("https://hinaria.com")?;
println!("{:?}", html);
// => "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\"> ..."Structs§
- Http
Client - an asynchronous, futures-based http client.
- Http
Content - the optional body of a http request.
- Http
Request - a http request.
- Http
Response - a http response, whose body can be read asynchronously.
- Http
Sync Client - a synchronous, blocking http client.
- Http
Sync Response - a http response, whose body can be read synchronously.
- Url
- simple access to a url and its components.
Enums§
- Http
Error - the error type for all errors in
crate simplist. - Http
Method - an enum for representing and comparing http methods.