mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-30 00:00:16 +02:00
chore: update futures to 0.3.0 (#1741)
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
|
||||
tokio-util = { version = "=0.2.0-alpha.6", path = "../tokio-util" }
|
||||
|
||||
bytes = "0.4.12"
|
||||
futures-preview = "=0.3.0-alpha.19"
|
||||
futures = "0.3.0"
|
||||
|
||||
[[example]]
|
||||
name = "chat"
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ use tokio::net::{TcpListener, TcpStream};
|
||||
use tokio::sync::{mpsc, Mutex};
|
||||
use tokio_util::codec::{Framed, LinesCodec, LinesCodecError};
|
||||
|
||||
use futures::{Poll, SinkExt, Stream, StreamExt};
|
||||
use futures::{SinkExt, Stream, StreamExt};
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
@@ -38,7 +38,7 @@ use std::io;
|
||||
use std::net::SocketAddr;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::task::Context;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
+11
-9
@@ -20,7 +20,7 @@ use tokio::io;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use tokio_util::codec::{FramedRead, FramedWrite};
|
||||
|
||||
use futures::{SinkExt, Stream};
|
||||
use futures::{SinkExt, Stream, StreamExt};
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
use std::net::SocketAddr;
|
||||
@@ -69,7 +69,7 @@ async fn run() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Temporary work around for stdin blocking the stream
|
||||
fn stdin() -> impl Stream<Item = Result<Vec<u8>, io::Error>> + Unpin {
|
||||
let mut stdin = FramedRead::new(io::stdin(), codec::Bytes);
|
||||
let mut stdin = FramedRead::new(io::stdin(), codec::Bytes).map(Ok);
|
||||
|
||||
let (mut tx, rx) = mpsc::unbounded_channel();
|
||||
|
||||
@@ -95,13 +95,15 @@ mod tcp {
|
||||
let mut stream = TcpStream::connect(addr).await?;
|
||||
let (r, w) = stream.split();
|
||||
let sink = FramedWrite::new(w, codec::Bytes);
|
||||
let mut stream = FramedRead::new(r, codec::Bytes).filter_map(|i| match i {
|
||||
Ok(i) => future::ready(Some(i)),
|
||||
Err(e) => {
|
||||
println!("failed to read from socket; error={}", e);
|
||||
future::ready(None)
|
||||
}
|
||||
});
|
||||
let mut stream = FramedRead::new(r, codec::Bytes)
|
||||
.filter_map(|i| match i {
|
||||
Ok(i) => future::ready(Some(i)),
|
||||
Err(e) => {
|
||||
println!("failed to read from socket; error={}", e);
|
||||
future::ready(None)
|
||||
}
|
||||
})
|
||||
.map(Ok);
|
||||
|
||||
match future::join(stdin.forward(sink), stdout.send_all(&mut stream)).await {
|
||||
(Err(e), _) | (_, Err(e)) => Err(e.into()),
|
||||
|
||||
Reference in New Issue
Block a user