Skip to content

Commit e44451a

Browse files
author
Stjepan Glavina
committed
Revamp IO traits and Stream trait
1 parent 43d822c commit e44451a

File tree

24 files changed

+1670
-90
lines changed

24 files changed

+1670
-90
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ futures-preview = "0.3.0-alpha.17"
2626
futures-timer = "0.3.0"
2727
lazy_static = "1.3.0"
2828
log = { version = "0.4.8", features = ["kv_unstable"] }
29+
memchr = "2.2.1"
2930
mio = "0.6.19"
3031
mio-uds = "0.6.7"
3132
num_cpus = "1.10.0"

src/fs/file.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ impl File {
483483
}
484484
}
485485

486-
impl AsyncRead for File {
486+
impl futures::io::AsyncRead for File {
487487
fn poll_read(
488488
self: Pin<&mut Self>,
489489
cx: &mut Context<'_>,
@@ -498,7 +498,7 @@ impl AsyncRead for File {
498498
}
499499
}
500500

501-
impl AsyncRead for &File {
501+
impl futures::io::AsyncRead for &File {
502502
fn poll_read(
503503
mut self: Pin<&mut Self>,
504504
cx: &mut Context<'_>,
@@ -564,7 +564,7 @@ impl AsyncRead for &File {
564564
}
565565
}
566566

567-
impl AsyncWrite for File {
567+
impl futures::io::AsyncWrite for File {
568568
fn poll_write(
569569
self: Pin<&mut Self>,
570570
cx: &mut Context<'_>,
@@ -582,7 +582,7 @@ impl AsyncWrite for File {
582582
}
583583
}
584584

585-
impl AsyncWrite for &File {
585+
impl futures::io::AsyncWrite for &File {
586586
fn poll_write(
587587
mut self: Pin<&mut Self>,
588588
cx: &mut Context<'_>,
@@ -693,7 +693,7 @@ impl AsyncWrite for &File {
693693
}
694694
}
695695

696-
impl AsyncSeek for File {
696+
impl futures::io::AsyncSeek for File {
697697
fn poll_seek(
698698
self: Pin<&mut Self>,
699699
cx: &mut Context<'_>,

src/future/mod.rs

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,8 @@
33
#[doc(inline)]
44
pub use std::future::Future;
55

6-
/// Never resolves to a value.
7-
///
8-
/// # Examples
9-
/// ```
10-
/// # #![feature(async_await)]
11-
/// # fn main() { async_std::task::block_on(async {
12-
/// #
13-
/// use async_std::future::pending;
14-
/// use async_std::prelude::*;
15-
/// use std::time::Duration;
16-
///
17-
/// let dur = Duration::from_secs(1);
18-
/// assert!(pending::<()>().timeout(dur).await.is_err());
19-
/// #
20-
/// # }) }
21-
/// ```
22-
pub async fn pending<T>() -> T {
23-
futures::future::pending::<T>().await
24-
}
6+
pub use pending::pending;
7+
pub use ready::ready;
258

26-
/// Resolves to the provided value.
27-
///
28-
/// This function is an async version of [`std::convert::identity`].
29-
///
30-
/// [`std::convert::identity`]: https://doc.rust-lang.org/std/convert/fn.identity.html
31-
///
32-
/// # Examples
33-
///
34-
/// ```
35-
/// # #![feature(async_await)]
36-
/// # fn main() { async_std::task::block_on(async {
37-
/// #
38-
/// use async_std::future::ready;
39-
///
40-
/// assert_eq!(ready(10).await, 10);
41-
/// #
42-
/// # }) }
43-
/// ```
44-
pub async fn ready<T>(val: T) -> T {
45-
val
46-
}
9+
mod pending;
10+
mod ready;

src/future/pending.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// Never resolves to a value.
2+
///
3+
/// # Examples
4+
/// ```
5+
/// # #![feature(async_await)]
6+
/// # fn main() { async_std::task::block_on(async {
7+
/// #
8+
/// use async_std::future::pending;
9+
/// use async_std::prelude::*;
10+
/// use std::time::Duration;
11+
///
12+
/// let dur = Duration::from_secs(1);
13+
/// assert!(pending::<()>().timeout(dur).await.is_err());
14+
/// #
15+
/// # }) }
16+
/// ```
17+
pub async fn pending<T>() -> T {
18+
futures::future::pending::<T>().await
19+
}

src/future/ready.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// Resolves to the provided value.
2+
///
3+
/// This function is an async version of [`std::convert::identity`].
4+
///
5+
/// [`std::convert::identity`]: https://doc.rust-lang.org/std/convert/fn.identity.html
6+
///
7+
/// # Examples
8+
///
9+
/// ```
10+
/// # #![feature(async_await)]
11+
/// # fn main() { async_std::task::block_on(async {
12+
/// #
13+
/// use async_std::future::ready;
14+
///
15+
/// assert_eq!(ready(10).await, 10);
16+
/// #
17+
/// # }) }
18+
/// ```
19+
pub async fn ready<T>(val: T) -> T {
20+
val
21+
}

0 commit comments

Comments
 (0)