summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLucio Franco <luciofranco14@gmail.com>2020-03-04 15:54:41 -0500
committerGitHub <noreply@github.com>2020-03-04 15:54:41 -0500
commit9d4d076189822e32574f8123efe21c732103f4d4 (patch)
treee0ff83c547bacfba77d8277246e219e8e73f04f4 /examples
parent1eb6131321b5bb8e0ccdb7b9433f6f0ef47821f2 (diff)
codec: change Encoder to take &Item (#1746)
Co-authored-by: Markus Westerlind <marwes91@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/Cargo.toml2
-rw-r--r--examples/chat.rs6
-rw-r--r--examples/tinydb.rs2
-rw-r--r--examples/tinyhttp.rs3
4 files changed, 5 insertions, 8 deletions
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 423ffe02..a25f526f 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2018"
[dev-dependencies]
tokio = { version = "0.2.0", path = "../tokio", features = ["full"] }
-tokio-util = { version = "0.2.0", path = "../tokio-util", features = ["full"] }
+tokio-util = { version = "0.3.0", path = "../tokio-util", features = ["full"] }
bytes = "0.5"
futures = "0.3.0"
http = "0.2"
diff --git a/examples/chat.rs b/examples/chat.rs
index fac43cbf..b3fb727a 100644
--- a/examples/chat.rs
+++ b/examples/chat.rs
@@ -193,9 +193,7 @@ async fn process(
let mut lines = Framed::new(stream, LinesCodec::new());
// Send a prompt to the client to enter their username.
- lines
- .send(String::from("Please enter your username:"))
- .await?;
+ lines.send("Please enter your username:").await?;
// Read the first line from the `LineCodec` stream to get the username.
let username = match lines.next().await {
@@ -232,7 +230,7 @@ async fn process(
// A message was received from a peer. Send it to the
// current user.
Ok(Message::Received(msg)) => {
- peer.lines.send(msg).await?;
+ peer.lines.send(&msg).await?;
}
Err(e) => {
println!(
diff --git a/examples/tinydb.rs b/examples/tinydb.rs
index 7c71dedf..c1af2541 100644
--- a/examples/tinydb.rs
+++ b/examples/tinydb.rs
@@ -130,7 +130,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
let response = response.serialize();
- if let Err(e) = lines.send(response).await {
+ if let Err(e) = lines.send(response.as_str()).await {
println!("error on sending response; error = {:?}", e);
}
}
diff --git a/examples/tinyhttp.rs b/examples/tinyhttp.rs
index 9ac2806e..732da0d6 100644
--- a/examples/tinyhttp.rs
+++ b/examples/tinyhttp.rs
@@ -96,8 +96,7 @@ struct Http;
/// Implementation of encoding an HTTP response into a `BytesMut`, basically
/// just writing out an HTTP/1.1 response.
-impl Encoder for Http {
- type Item = Response<String>;
+impl Encoder<Response<String>> for Http {
type Error = io::Error;
fn encode(&mut self, item: Response<String>, dst: &mut BytesMut) -> io::Result<()> {