tokio_io/lib.rs
1#![deny(missing_docs, missing_debug_implementations)]
2#![doc(html_root_url = "https://docs.rs/tokio-io/0.1.13")]
3
4//! Core I/O traits and combinators when working with Tokio.
5//!
6//! > **Note:** This crate has been **deprecated in tokio 0.2.x** and has been
7//! > moved into [`tokio::io`].
8//!
9//! [`tokio::io`]: https://docs.rs/tokio/latest/tokio/io/index.html
10//!
11//! A description of the high-level I/O combinators can be [found online] in
12//! addition to a description of the [low level details].
13//!
14//! [found online]: https://tokio.rs/docs/getting-started/core/
15//! [low level details]: https://tokio.rs/docs/going-deeper-tokio/core-low-level/
16
17#[macro_use]
18extern crate log;
19
20#[macro_use]
21extern crate futures;
22extern crate bytes;
23
24use std::io as std_io;
25
26use futures::{Future, Stream};
27
28/// A convenience typedef around a `Future` whose error component is `io::Error`
29pub type IoFuture<T> = Box<dyn Future<Item = T, Error = std_io::Error> + Send>;
30
31/// A convenience typedef around a `Stream` whose error component is `io::Error`
32pub type IoStream<T> = Box<dyn Stream<Item = T, Error = std_io::Error> + Send>;
33
34/// A convenience macro for working with `io::Result<T>` from the `Read` and
35/// `Write` traits.
36///
37/// This macro takes `io::Result<T>` as input, and returns `T` as the output. If
38/// the input type is of the `Err` variant, then `Poll::NotReady` is returned if
39/// it indicates `WouldBlock` or otherwise `Err` is returned.
40#[macro_export]
41macro_rules! try_nb {
42 ($e:expr) => {
43 match $e {
44 Ok(t) => t,
45 Err(ref e) if e.kind() == ::std::io::ErrorKind::WouldBlock => {
46 return Ok(::futures::Async::NotReady);
47 }
48 Err(e) => return Err(e.into()),
49 }
50 };
51}
52
53pub mod codec;
54pub mod io;
55
56pub mod _tokio_codec;
57mod allow_std;
58mod async_read;
59mod async_write;
60mod framed;
61mod framed_read;
62mod framed_write;
63mod length_delimited;
64mod lines;
65mod split;
66mod window;
67
68pub use self::async_read::AsyncRead;
69pub use self::async_write::AsyncWrite;
70
71fn _assert_objects() {
72 fn _assert<T>() {}
73 _assert::<Box<dyn AsyncRead>>();
74 _assert::<Box<dyn AsyncWrite>>();
75}