diff options
author | Bryan Burgers <bryan@burgers.io> | 2018-06-04 22:36:06 -0500 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2018-06-04 20:36:06 -0700 |
commit | f723d100871e025e4bdd2f47397c9b089e666ce0 (patch) | |
tree | 7d67d7f8bee561f6f04b9d1222dd02719fb47b12 /examples/tinyhttp.rs | |
parent | 3d7263d3a0b73ab35d63b45a6524bde7251851e8 (diff) |
Create tokio-codec (#360)
Create a new tokio-codec crate with many of the contents of
`tokio_io::codec`.
Diffstat (limited to 'examples/tinyhttp.rs')
-rw-r--r-- | examples/tinyhttp.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/tinyhttp.rs b/examples/tinyhttp.rs index 9bf3f27a..d56ff96f 100644 --- a/examples/tinyhttp.rs +++ b/examples/tinyhttp.rs @@ -21,6 +21,7 @@ extern crate serde_derive; extern crate serde_json; extern crate time; extern crate tokio; +extern crate tokio_codec; extern crate tokio_io; use std::{env, fmt, io}; @@ -29,7 +30,7 @@ use std::net::SocketAddr; use tokio::net::{TcpStream, TcpListener}; use tokio::prelude::*; -use tokio_io::codec::{Encoder, Decoder}; +use tokio_codec::{Encoder, Decoder}; use bytes::BytesMut; use http::header::HeaderValue; @@ -55,10 +56,10 @@ fn main() { } fn process(socket: TcpStream) { - let (tx, rx) = socket + let (tx, rx) = // Frame the socket using the `Http` protocol. This maps the TCP socket // to a Stream + Sink of HTTP frames. - .framed(Http) + Http.framed(socket) // This splits a single `Stream + Sink` value into two separate handles // that can be used independently (even on different tasks or threads). .split(); |