Skip to content

Commit bac93e3

Browse files
committed
Update to Tokio 0.3
1 parent 0d87d2d commit bac93e3

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ lazy_static = "1.4.0"
2626
regex = "1.3.9"
2727
chrono = "0.4.11"
2828

29-
tokio = { version = "0.2.21", features = ["tcp", "dns", "io-util"] }
30-
tokio-rustls = { version = "0.13.1", optional = true }
31-
pin-project = "0.4.17"
29+
tokio = { version = "0.3.1", features = ["net", "io-util"] }
30+
tokio-rustls = { version = "0.20.0", optional = true }
31+
pin-project = "1.0.0"
32+
33+
[dev-dependencies]
34+
tokio = { version = "0.3.1", features = ["macros", "stream", "rt"] }
35+
tokio-util = { version = "0.4.0", features = ["io"] }
3236

33-
[dev-dependencies.tokio]
34-
version = "0.2.21"
35-
features = [ "macros", "stream", "io-util" ]

examples/connecting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async fn test_ftp(addr: &str, user: &str, pass: &str) -> Result<(), FtpError> {
2626
fn main() {
2727
let future = test_ftp("172.25.82.139", "anonymous", "[email protected]");
2828

29-
tokio::runtime::Builder::new()
29+
tokio::runtime::Builder::new_current_thread()
3030
.enable_all()
3131
.build()
3232
.unwrap()

src/data_stream.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::io;
22
use std::pin::Pin;
33
use std::task::{Context, Poll};
4-
use tokio::io::{AsyncRead, AsyncWrite};
4+
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
55
use tokio::net::TcpStream;
66
#[cfg(feature = "secure")]
77
use tokio_rustls::client::TlsStream;
@@ -47,8 +47,8 @@ impl AsyncRead for DataStream {
4747
fn poll_read(
4848
self: Pin<&mut Self>,
4949
cx: &mut Context<'_>,
50-
buf: &mut [u8],
51-
) -> Poll<io::Result<usize>> {
50+
buf: &mut ReadBuf<'_>,
51+
) -> Poll<io::Result<()>> {
5252
match self.project() {
5353
DataStreamProj::Tcp(stream) => stream.poll_read(cx, buf),
5454
#[cfg(feature = "secure")]

src/ftp.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,12 @@ impl FtpStream {
617617
#[cfg(test)]
618618
mod tests {
619619
use super::FtpStream;
620-
use tokio::{io::stream_reader, stream};
620+
use tokio::{stream};
621+
use tokio_util::io::StreamReader;
621622

622623
#[tokio::test]
623624
async fn list_command_dos_newlines() {
624-
let data_stream = stream_reader(stream::once(Ok(
625+
let data_stream = StreamReader::new(stream::once(Ok::<_, std::io::Error>(
625626
b"Hello\r\nWorld\r\n\r\nBe\r\nHappy\r\n" as &[u8]
626627
)));
627628

@@ -636,7 +637,7 @@ mod tests {
636637

637638
#[tokio::test]
638639
async fn list_command_unix_newlines() {
639-
let data_stream = stream_reader(stream::once(Ok(b"Hello\nWorld\n\nBe\nHappy\n" as &[u8])));
640+
let data_stream = StreamReader::new(stream::once(Ok::<_, std::io::Error>(b"Hello\nWorld\n\nBe\nHappy\n" as &[u8])));
640641

641642
assert_eq!(
642643
FtpStream::get_lines_from_stream(data_stream).await.unwrap(),

tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn test_ftp() {
3636
Ok(())
3737
};
3838

39-
let result: Result<(), FtpError> = tokio::runtime::Builder::new()
39+
let result: Result<(), FtpError> = tokio::runtime::Builder::new_current_thread()
4040
.enable_all()
4141
.build()
4242
.unwrap()

0 commit comments

Comments
 (0)