docs: improve tokio::io API documentation (#1815)

Adds method level documentation for `tokio::io`.
This commit is contained in:
Carl Lerche
2019-11-23 08:24:03 -08:00
committed by GitHub
parent 0bc68adb34
commit 3ecaa6d91c
10 changed files with 493 additions and 71 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ async fn echo_server() {
let (mut a, _) = assert_ok!(srv.accept().await);
let (mut b, _) = assert_ok!(srv.accept().await);
let n = assert_ok!(a.copy(&mut b).await);
let n = assert_ok!(io::copy(&mut a, &mut b).await);
let (expected, t2) = t.join().unwrap();
let actual = t2.join().unwrap();
+2 -3
View File
@@ -1,10 +1,9 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio::io::{self, AsyncRead};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
@@ -31,7 +30,7 @@ async fn copy() {
let mut rd = Rd(true);
let mut wr = Vec::new();
let n = assert_ok!(rd.copy(&mut wr).await);
let n = assert_ok!(io::copy(&mut rd, &mut wr).await);
assert_eq!(n, 11);
assert_eq!(wr, b"hello world");
}
+1 -1
View File
@@ -35,7 +35,7 @@ async fn echo_server() {
let (mut stream, _) = assert_ok!(srv.accept().await);
let (mut rd, mut wr) = stream.split();
let n = assert_ok!(rd.copy(&mut wr).await);
let n = assert_ok!(io::copy(&mut rd, &mut wr).await);
assert_eq!(n, (ITER * msg.len()) as u64);
assert_ok!(rx.await);
+2 -2
View File
@@ -1,7 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncWriteExt;
use tokio::io::{self, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::prelude::*;
use tokio_test::assert_ok;
@@ -24,6 +24,6 @@ async fn shutdown() {
let (mut stream, _) = assert_ok!(srv.accept().await);
let (mut rd, mut wr) = stream.split();
let n = assert_ok!(rd.copy(&mut wr).await);
let n = assert_ok!(io::copy(&mut rd, &mut wr).await);
assert_eq!(n, 0);
}