mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-18 00:00:09 +02:00
tokio: re-export future/stream utils (#1387)
This commit is contained in:
+2
-1
@@ -62,7 +62,8 @@ uds = ["tokio-uds"]
|
||||
[dependencies]
|
||||
# Only non-optional dependency...
|
||||
#futures = "0.1.20"
|
||||
futures-core-preview = "0.3.0-alpha.17"
|
||||
futures-core-preview = "= 0.3.0-alpha.17"
|
||||
futures-util-preview = "= 0.3.0-alpha.17"
|
||||
|
||||
# Everything else is optional...
|
||||
bytes = { version = "0.4", optional = true }
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
#![feature(async_await)]
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
|
||||
use tokio::io;
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::prelude::*;
|
||||
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
use std::net::SocketAddr;
|
||||
use std::time::Duration;
|
||||
|
||||
use tokio::io;
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::util::FutureExt;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let _ = env_logger::init();
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
//! Asynchronous values.
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
use tokio_timer::Timeout;
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
use std::time::Duration;
|
||||
|
||||
use std::future::Future;
|
||||
#[doc(inline)]
|
||||
pub use futures_util::future::{err, ok, pending, poll_fn, ready};
|
||||
#[doc(inline)]
|
||||
pub use std::future::Future;
|
||||
|
||||
/// An extension trait for `Future` that provides a variety of convenient
|
||||
/// combinator functions.
|
||||
+5
-1
@@ -81,6 +81,7 @@ pub mod clock;
|
||||
pub mod codec;
|
||||
#[cfg(feature = "fs")]
|
||||
pub mod fs;
|
||||
pub mod future;
|
||||
#[cfg(feature = "io")]
|
||||
pub mod io;
|
||||
#[cfg(any(feature = "tcp", feature = "udp", feature = "uds"))]
|
||||
@@ -88,19 +89,22 @@ pub mod net;
|
||||
pub mod prelude;
|
||||
#[cfg(feature = "reactor")]
|
||||
pub mod reactor;
|
||||
pub mod stream;
|
||||
#[cfg(feature = "sync")]
|
||||
pub mod sync;
|
||||
#[cfg(feature = "timer")]
|
||||
pub mod timer;
|
||||
pub mod util;
|
||||
|
||||
if_runtime! {
|
||||
pub mod executor;
|
||||
pub mod runtime;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use crate::executor::spawn;
|
||||
|
||||
#[cfg(not(test))] // Work around for rust-lang/rust#62127
|
||||
#[doc(inline)]
|
||||
pub use tokio_macros::main;
|
||||
#[doc(inline)]
|
||||
pub use tokio_macros::test;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,13 @@
|
||||
//!
|
||||
//! The prelude may grow over time as additional items see ubiquitous use.
|
||||
|
||||
pub use crate::util::FutureExt;
|
||||
pub use crate::future::FutureExt as _;
|
||||
pub use futures_util::future::FutureExt as _;
|
||||
pub use std::future::Future;
|
||||
|
||||
pub use crate::stream::{Stream, StreamExt as _};
|
||||
pub use futures_util::stream::StreamExt as _;
|
||||
|
||||
#[cfg(feature = "io")]
|
||||
pub use tokio_io::{
|
||||
AsyncBufRead, AsyncBufReadExt as _, AsyncRead, AsyncReadExt as _, AsyncWrite,
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
//! A sequence of asynchronous values.
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
use tokio_timer::{throttle::Throttle, Timeout};
|
||||
|
||||
use futures_core::Stream;
|
||||
#[doc(inline)]
|
||||
pub use futures_core::Stream;
|
||||
#[doc(inline)]
|
||||
pub use futures_util::stream::{empty, iter, once, pending, poll_fn, repeat, unfold};
|
||||
|
||||
/// An extension trait for `Stream` that provides a variety of convenient
|
||||
/// combinator functions.
|
||||
@@ -1,14 +0,0 @@
|
||||
//! Utilities for working with Tokio.
|
||||
//!
|
||||
//! This module contains utilities that are useful for working with Tokio.
|
||||
//! Currently, this only includes [`FutureExt`] and [`StreamExt`], but this
|
||||
//! may grow over time.
|
||||
//!
|
||||
//! [`FutureExt`]: trait.FutureExt.html
|
||||
//! [`StreamExt`]: trait.StreamExt.html
|
||||
|
||||
mod future;
|
||||
mod stream;
|
||||
|
||||
pub use self::future::FutureExt;
|
||||
pub use self::stream::StreamExt;
|
||||
Reference in New Issue
Block a user