From 49a7e5f5e7b71cd8e132f612582d7334fc65dae3 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Thu, 18 Apr 2019 20:17:38 +0200 Subject: [PATCH 01/17] Add first example, update README --- .gitignore | 6 ------ README.md | 11 ++++++++--- examples/simple_response.rs | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 examples/simple_response.rs diff --git a/.gitignore b/.gitignore index 6310b55..088ba6b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -<<<<<<< HEAD # Generated by Cargo # will have compiled files and executables /target/ @@ -9,8 +8,3 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk -======= -/target -**/*.rs.bk -Cargo.lock ->>>>>>> Initial commit diff --git a/README.md b/README.md index 41cdb2b..8ab45f2 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ -# http-service +

http-service

+
+ + Types and traits giving an interface between low-level http server implementations and services that use them. The interface is based on the `std::futures` API. + +
+ +
[![build status][1]][2] -Types and traits giving an interface between low-level http server implementations -and services that use them. The interface is based on the `std::futures` API. ## License diff --git a/examples/simple_response.rs b/examples/simple_response.rs new file mode 100644 index 0000000..dc8fbf9 --- /dev/null +++ b/examples/simple_response.rs @@ -0,0 +1,37 @@ +#![feature(futures_api, async_await, await_macro, existential_type)] + +use futures::{ + future::{self, FutureObj}, +}; +use http_service::{HttpService, Response}; + +struct Server { + message: Vec, +} + +impl Server { + fn create(message: Vec) -> Server { + Server { + message, + } + } +} + +impl HttpService for Server { + type Connection = (); + type ConnectionFuture = future::Ready>; + type Fut = FutureObj<'static, Result>; + + fn connect(&self) -> Self::ConnectionFuture { + future::ok(()) + } + + fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::Fut { + let message = self.message.clone(); + FutureObj::new(Box::new( + async move { + Ok(Response::new(http_service::Body::from(message))) + } + )) + } +} \ No newline at end of file From 31e4f84031bb8ac4d84cc002f6ef030e2690a4ee Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Fri, 19 Apr 2019 07:14:21 +0200 Subject: [PATCH 02/17] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ab45f2..2e6aee4 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@

http-service

- Types and traits giving an interface between low-level http server implementations and services that use them. The interface is based on the `std::futures` API. + Types and traits to help you implement your own HTTP server

+ [![build status][1]][2] From 7844f703fdce97cba7b7424c652beb78ad4eed8e Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Fri, 19 Apr 2019 07:32:10 +0200 Subject: [PATCH 03/17] Formatting --- examples/simple_response.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/examples/simple_response.rs b/examples/simple_response.rs index dc8fbf9..a7a4c02 100644 --- a/examples/simple_response.rs +++ b/examples/simple_response.rs @@ -1,8 +1,6 @@ #![feature(futures_api, async_await, await_macro, existential_type)] -use futures::{ - future::{self, FutureObj}, -}; +use futures::future::{self, FutureObj}; use http_service::{HttpService, Response}; struct Server { @@ -11,9 +9,7 @@ struct Server { impl Server { fn create(message: Vec) -> Server { - Server { - message, - } + Server { message } } } @@ -21,17 +17,15 @@ impl HttpService for Server { type Connection = (); type ConnectionFuture = future::Ready>; type Fut = FutureObj<'static, Result>; - + fn connect(&self) -> Self::ConnectionFuture { future::ok(()) } fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::Fut { let message = self.message.clone(); - FutureObj::new(Box::new( - async move { - Ok(Response::new(http_service::Body::from(message))) - } - )) + FutureObj::new(Box::new(async move { + Ok(Response::new(http_service::Body::from(message))) + })) } -} \ No newline at end of file +} From 27358ad35e2966a59b0328e5f739048cdf982512 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Sun, 21 Apr 2019 05:41:14 +0200 Subject: [PATCH 04/17] Update README.md --- README.md | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2e6aee4..1009866 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,116 @@
+
+ + + Crates.io version + + + + Build Status + + + + Download + + + + docs.rs docs + +
+ + + +
+ Built with ⛵ by The Rust Async Ecosystem WG +
+ +## About +The crate `http-service` provides the necessary types and traits to implement your own HTTP Server. It uses `hyper` for the lower level TCP abstraction. + +You can use the workspace member [`http-service-hyper`](https://crates.io/crates/http-service-hyper) to run your HTTP Server via `http_service_hyper::serve(HTTP_SERVICE, ADDRESS);` + +This crate uses the latest [Futures](https://github.com/rust-lang-nursery/futures-rs) preview, and therefore needs to be run on Rust Nightly. -[![build status][1]][2] +## Examples +**Cargo.toml** +``` +[dependencies] +http-service = "0.1.5" +futures-preview = "0.3.0-alpha.14" + +[dependencies.http-service-hyper] +version = "0.1.1" +``` + +**main.rs** +```rust +#![feature(futures_api, async_await, await_macro, existential_type)] + +use futures::{ + future::{self, FutureObj}, +}; +use http_service::{HttpService, Response}; +use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + +struct Server { + message: Vec, +} + +impl Server { + fn create(message: Vec) -> Server { + Server { + message, + } + } + + pub fn serve(s: Server) { + let a = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); + http_service_hyper::serve(s, a); + } +} + +impl HttpService for Server { + type Connection = (); + type ConnectionFuture = future::Ready>; + type Fut = FutureObj<'static, Result>; + + fn connect(&self) -> Self::ConnectionFuture { + future::ok(()) + } + + fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::Fut { + let message = self.message.clone(); + FutureObj::new(Box::new( + async move { + Ok(Response::new(http_service::Body::from(message))) + } + )) + } +} + +fn main() { + let s = Server::create(String::from("Hello, World").into_bytes()); + Server::serve(s); +} +``` ## License [MIT](./LICENSE-MIT) OR [Apache-2.0](./LICENSE-APACHE) - -[1]: https://img.shields.io/travis/rust-net-web/http-service.svg?style=flat-square -[2]: https://travis-ci.org/rust-net-web/http-service From bf30915d5299bab45ed4f19db92002a321d47859 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Sun, 21 Apr 2019 05:50:19 +0200 Subject: [PATCH 05/17] Add example to lib.rs --- src/lib.rs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 8289093..9620715 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,56 @@ //! Types and traits giving an interface between low-level http server implementations //! and services that use them. The interface is based on the `std::futures` API. +//! #![feature(futures_api, async_await, await_macro, existential_type)] +//! +//! ## Example +//! ```no_run +//! use futures::{ +//! future::{self, FutureObj}, +//! }; +//! use http_service::{HttpService, Response}; +//! use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +//! +//! struct Server { +//! message: Vec, +//! } +//! +//! impl Server { +//! fn create(message: Vec) -> Server { +//! Server { +//! message, +//! } +//! } +//! +//! pub fn serve(s: Server) { +//! let a = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); +//! http_service_hyper::serve(s, a); +//! } +//! } +//! +//! impl HttpService for Server { +//! type Connection = (); +//! type ConnectionFuture = future::Ready>; +//! type Fut = FutureObj<'static, Result>; +//! +//! fn connect(&self) -> Self::ConnectionFuture { +//! future::ok(()) +//! } +//! +//! fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::Fut { +//! let message = self.message.clone(); +//! FutureObj::new(Box::new( +//! async move { +//! Ok(Response::new(http_service::Body::from(message))) +//! } +//! )) +//! } +//! } +//! +//! fn main() { +//! let s = Server::create(String::from("Hello, World").into_bytes()); +//! Server::serve(s); +//! } +//! ``` #![forbid(future_incompatible, rust_2018_idioms)] #![deny(missing_debug_implementations, nonstandard_style)] From e634ca3a97762f5bc5d82b8b126bace1d3497a81 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Tue, 23 Apr 2019 09:46:04 +0200 Subject: [PATCH 06/17] Add main() to examples so it compiles --- examples/simple_response.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/simple_response.rs b/examples/simple_response.rs index a7a4c02..52aa2e5 100644 --- a/examples/simple_response.rs +++ b/examples/simple_response.rs @@ -2,6 +2,7 @@ use futures::future::{self, FutureObj}; use http_service::{HttpService, Response}; +use std::net::{IpAddr, Ipv4Addr, SocketAddr}; struct Server { message: Vec, @@ -11,6 +12,11 @@ impl Server { fn create(message: Vec) -> Server { Server { message } } + + pub fn serve(s: Server) { + let a = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); + http_service_hyper::serve(s, a); + } } impl HttpService for Server { @@ -29,3 +35,8 @@ impl HttpService for Server { })) } } + +fn main() { + let s = Server::create(String::from("Hello, World").into_bytes()); + Server::serve(s); +} \ No newline at end of file From 455435fc7007515dae4a1370d91a7c44ecdb26b3 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Tue, 23 Apr 2019 15:31:02 +0200 Subject: [PATCH 07/17] cargo fmt --- examples/simple_response.rs | 2 +- src/lib.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/simple_response.rs b/examples/simple_response.rs index 52aa2e5..fe02ba8 100644 --- a/examples/simple_response.rs +++ b/examples/simple_response.rs @@ -39,4 +39,4 @@ impl HttpService for Server { fn main() { let s = Server::create(String::from("Hello, World").into_bytes()); Server::serve(s); -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index 9620715..047ce95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ //! Types and traits giving an interface between low-level http server implementations //! and services that use them. The interface is based on the `std::futures` API. //! #![feature(futures_api, async_await, await_macro, existential_type)] -//! +//! //! ## Example //! ```no_run //! use futures::{ @@ -9,24 +9,24 @@ //! }; //! use http_service::{HttpService, Response}; //! use std::net::{IpAddr, Ipv4Addr, SocketAddr}; -//! +//! //! struct Server { //! message: Vec, //! } -//! +//! //! impl Server { //! fn create(message: Vec) -> Server { //! Server { //! message, //! } //! } -//! +//! //! pub fn serve(s: Server) { //! let a = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); //! http_service_hyper::serve(s, a); //! } //! } -//! +//! //! impl HttpService for Server { //! type Connection = (); //! type ConnectionFuture = future::Ready>; @@ -35,7 +35,7 @@ //! fn connect(&self) -> Self::ConnectionFuture { //! future::ok(()) //! } -//! +//! //! fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::Fut { //! let message = self.message.clone(); //! FutureObj::new(Box::new( @@ -45,7 +45,7 @@ //! )) //! } //! } -//! +//! //! fn main() { //! let s = Server::create(String::from("Hello, World").into_bytes()); //! Server::serve(s); From 00f630b611dfcdbef2de5a89186da286309373ad Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Tue, 23 Apr 2019 19:07:02 +0200 Subject: [PATCH 08/17] Add dev-dependency for http-service-hyper --- Cargo.toml | 3 +++ examples/simple_response.rs | 18 ++++++++++++------ http-service-mock/src/lib.rs | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 957466c..b8fd647 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,8 @@ members = ["http-service-hyper", "http-service-mock"] bytes = "0.4.12" http = "0.1.17" +[dev-dependencies] +http-service-hyper = { path = "http-service-hyper", version = "0.1.1" } + [dependencies.futures-preview] version = "0.3.0-alpha.14" diff --git a/examples/simple_response.rs b/examples/simple_response.rs index fe02ba8..d86eb8b 100644 --- a/examples/simple_response.rs +++ b/examples/simple_response.rs @@ -1,6 +1,8 @@ #![feature(futures_api, async_await, await_macro, existential_type)] -use futures::future::{self, FutureObj}; +use futures::{ + future::{self, FutureObj}, +}; use http_service::{HttpService, Response}; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; @@ -10,7 +12,9 @@ struct Server { impl Server { fn create(message: Vec) -> Server { - Server { message } + Server { + message, + } } pub fn serve(s: Server) { @@ -23,16 +27,18 @@ impl HttpService for Server { type Connection = (); type ConnectionFuture = future::Ready>; type Fut = FutureObj<'static, Result>; - + fn connect(&self) -> Self::ConnectionFuture { future::ok(()) } fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::Fut { let message = self.message.clone(); - FutureObj::new(Box::new(async move { - Ok(Response::new(http_service::Body::from(message))) - })) + FutureObj::new(Box::new( + async move { + Ok(Response::new(http_service::Body::from(message))) + } + )) } } diff --git a/http-service-mock/src/lib.rs b/http-service-mock/src/lib.rs index e2f1ec3..200f24d 100644 --- a/http-service-mock/src/lib.rs +++ b/http-service-mock/src/lib.rs @@ -15,7 +15,7 @@ pub struct TestBackend { service: T, connection: T::Connection, } - +  impl TestBackend { fn wrap(service: T) -> Result::Error> { let connection = block_on(service.connect().into_future())?; From c2ceb4beb148a22c487ce7e5fdbb4a4592ee7def Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Tue, 23 Apr 2019 19:09:45 +0200 Subject: [PATCH 09/17] fmt --- examples/simple_response.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/examples/simple_response.rs b/examples/simple_response.rs index d86eb8b..fe02ba8 100644 --- a/examples/simple_response.rs +++ b/examples/simple_response.rs @@ -1,8 +1,6 @@ #![feature(futures_api, async_await, await_macro, existential_type)] -use futures::{ - future::{self, FutureObj}, -}; +use futures::future::{self, FutureObj}; use http_service::{HttpService, Response}; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; @@ -12,9 +10,7 @@ struct Server { impl Server { fn create(message: Vec) -> Server { - Server { - message, - } + Server { message } } pub fn serve(s: Server) { @@ -27,18 +23,16 @@ impl HttpService for Server { type Connection = (); type ConnectionFuture = future::Ready>; type Fut = FutureObj<'static, Result>; - + fn connect(&self) -> Self::ConnectionFuture { future::ok(()) } fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::Fut { let message = self.message.clone(); - FutureObj::new(Box::new( - async move { - Ok(Response::new(http_service::Body::from(message))) - } - )) + FutureObj::new(Box::new(async move { + Ok(Response::new(http_service::Body::from(message))) + })) } } From a2256419307de9d49beab1f421c3045016e56c3c Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Tue, 23 Apr 2019 19:13:16 +0200 Subject: [PATCH 10/17] fmt --- http-service-mock/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-service-mock/src/lib.rs b/http-service-mock/src/lib.rs index 200f24d..e2f1ec3 100644 --- a/http-service-mock/src/lib.rs +++ b/http-service-mock/src/lib.rs @@ -15,7 +15,7 @@ pub struct TestBackend { service: T, connection: T::Connection, } -  + impl TestBackend { fn wrap(service: T) -> Result::Error> { let connection = block_on(service.connect().into_future())?; From 26e1d51df0b44eb039c705500d19d02ab2644a67 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Tue, 23 Apr 2019 21:28:20 +0200 Subject: [PATCH 11/17] Use `run` instead of `serve` --- examples/simple_response.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/simple_response.rs b/examples/simple_response.rs index fe02ba8..f519eec 100644 --- a/examples/simple_response.rs +++ b/examples/simple_response.rs @@ -13,9 +13,9 @@ impl Server { Server { message } } - pub fn serve(s: Server) { + pub fn run(s: Server) { let a = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); - http_service_hyper::serve(s, a); + http_service_hyper::run(s, a); } } @@ -38,5 +38,5 @@ impl HttpService for Server { fn main() { let s = Server::create(String::from("Hello, World").into_bytes()); - Server::serve(s); + Server::run(s); } From ef9c186a64fb776552604c07f6ff9fea1ebb0aa7 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Tue, 23 Apr 2019 21:37:00 +0200 Subject: [PATCH 12/17] fmt --- examples/simple_response.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/simple_response.rs b/examples/simple_response.rs index f519eec..7d1916b 100644 --- a/examples/simple_response.rs +++ b/examples/simple_response.rs @@ -15,7 +15,7 @@ impl Server { pub fn run(s: Server) { let a = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); - http_service_hyper::run(s, a); + http_service_hyper::serve(s, a); } } @@ -38,5 +38,5 @@ impl HttpService for Server { fn main() { let s = Server::create(String::from("Hello, World").into_bytes()); - Server::run(s); + Server::serve(s); } From 98a8f88cb255bce51c548cddbd3409ba2df8dcb8 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Tue, 23 Apr 2019 21:49:19 +0200 Subject: [PATCH 13/17] Change back to run --- examples/simple_response.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/simple_response.rs b/examples/simple_response.rs index 7d1916b..f519eec 100644 --- a/examples/simple_response.rs +++ b/examples/simple_response.rs @@ -15,7 +15,7 @@ impl Server { pub fn run(s: Server) { let a = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); - http_service_hyper::serve(s, a); + http_service_hyper::run(s, a); } } @@ -38,5 +38,5 @@ impl HttpService for Server { fn main() { let s = Server::create(String::from("Hello, World").into_bytes()); - Server::serve(s); + Server::run(s); } From 6d2e1cc943ebeb1759d873f27e7758b6045a321d Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 24 Apr 2019 17:59:30 +0200 Subject: [PATCH 14/17] Fix dependencies --- http-service-hyper/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-service-hyper/Cargo.toml b/http-service-hyper/Cargo.toml index 1ddc125..a2e1156 100644 --- a/http-service-hyper/Cargo.toml +++ b/http-service-hyper/Cargo.toml @@ -13,7 +13,7 @@ version = "0.1.1" [dependencies] http = "0.1" -http-service = "0.1.5" +http-service = { version = "0.1.5", path = ".." } hyper = "0.12.27" [dependencies.futures-preview] From a71b281682a5c72a14158f8ec8c0d3a6de00cbbe Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 24 Apr 2019 18:19:58 +0200 Subject: [PATCH 15/17] Fmt, update example --- README.md | 24 +++++++++--------------- src/lib.rs | 11 ++++++----- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 1009866..10f3b59 100644 --- a/README.md +++ b/README.md @@ -69,9 +69,7 @@ version = "0.1.1" ```rust #![feature(futures_api, async_await, await_macro, existential_type)] -use futures::{ - future::{self, FutureObj}, -}; +use futures::future::{self, FutureObj}; use http_service::{HttpService, Response}; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; @@ -81,14 +79,12 @@ struct Server { impl Server { fn create(message: Vec) -> Server { - Server { - message, - } + Server { message } } - pub fn serve(s: Server) { + pub fn run(s: Server) { let a = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); - http_service_hyper::serve(s, a); + http_service_hyper::run(s, a); } } @@ -96,24 +92,22 @@ impl HttpService for Server { type Connection = (); type ConnectionFuture = future::Ready>; type Fut = FutureObj<'static, Result>; - + fn connect(&self) -> Self::ConnectionFuture { future::ok(()) } fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::Fut { let message = self.message.clone(); - FutureObj::new(Box::new( - async move { - Ok(Response::new(http_service::Body::from(message))) - } - )) + FutureObj::new(Box::new(async move { + Ok(Response::new(http_service::Body::from(message))) + })) } } fn main() { let s = Server::create(String::from("Hello, World").into_bytes()); - Server::serve(s); + Server::run(s); } ``` diff --git a/src/lib.rs b/src/lib.rs index 047ce95..b25f8f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,10 @@ //! Types and traits giving an interface between low-level http server implementations //! and services that use them. The interface is based on the `std::futures` API. -//! #![feature(futures_api, async_await, await_macro, existential_type)] //! //! ## Example -//! ```no_run +//! ```rust,no_run +//! #![feature(futures_api, async_await, await_macro, existential_type)] +//! //! use futures::{ //! future::{self, FutureObj}, //! }; @@ -21,9 +22,9 @@ //! } //! } //! -//! pub fn serve(s: Server) { +//! pub fn run(s: Server) { //! let a = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); -//! http_service_hyper::serve(s, a); +//! http_service_hyper::run(s, a); //! } //! } //! @@ -48,7 +49,7 @@ //! //! fn main() { //! let s = Server::create(String::from("Hello, World").into_bytes()); -//! Server::serve(s); +//! Server::run(s); //! } //! ``` From 0b676f4605f821769b5a6bb2d44e6c4df53f4498 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 24 Apr 2019 18:23:04 +0200 Subject: [PATCH 16/17] Remove not needed line in docs --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b25f8f3..2741f99 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,6 @@ //! ## Example //! ```rust,no_run //! #![feature(futures_api, async_await, await_macro, existential_type)] -//! //! use futures::{ //! future::{self, FutureObj}, //! }; From 65c69a90b8044f7ca9fdb99f0f4219a7823a8e02 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 24 Apr 2019 18:55:49 +0200 Subject: [PATCH 17/17] Ignore doc code --- src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2741f99..cdbffb2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,8 +2,9 @@ //! and services that use them. The interface is based on the `std::futures` API. //! //! ## Example -//! ```rust,no_run +//! ```no_run, rust, ignore //! #![feature(futures_api, async_await, await_macro, existential_type)] +//! //! use futures::{ //! future::{self, FutureObj}, //! }; @@ -29,9 +30,9 @@ //! //! impl HttpService for Server { //! type Connection = (); -//! type ConnectionFuture = future::Ready>; +//! type ConnectionFuture = future::Ready>; //! type Fut = FutureObj<'static, Result>; -//! +//! //! fn connect(&self) -> Self::ConnectionFuture { //! future::ok(()) //! }