#![deprecated(note = "moved to the `tokio-io` crate")]
#![allow(deprecated)]
use std::io;
use futures::{Async, Poll};
use futures::future::BoxFuture;
use futures::stream::BoxStream;
use iovec::IoVec;
pub type IoFuture<T> = BoxFuture<T, io::Error>;
pub type IoStream<T> = BoxStream<T, io::Error>;
#[macro_export]
macro_rules! try_nb {
($e:expr) => (match $e {
Ok(t) => t,
Err(ref e) if e.kind() == ::std::io::ErrorKind::WouldBlock => {
return Ok(::futures::Async::NotReady)
}
Err(e) => return Err(e.into()),
})
}
mod copy;
mod frame;
mod flush;
mod read_exact;
mod read_to_end;
mod read;
mod read_until;
mod split;
mod window;
mod write_all;
pub use self::copy::{copy, Copy};
pub use self::frame::{EasyBuf, EasyBufMut, Framed, Codec};
pub use self::flush::{flush, Flush};
pub use self::read_exact::{read_exact, ReadExact};
pub use self::read_to_end::{read_to_end, ReadToEnd};
pub use self::read::{read, Read};
pub use self::read_until::{read_until, ReadUntil};
pub use self::split::{ReadHalf, WriteHalf};
pub use self::window::Window;
pub use self::write_all::{write_all, WriteAll};
pub trait Io: io::Read + io::Write {
fn poll_read(&mut self) -> Async<()> {
Async::Ready(())
}
fn poll_write(&mut self) -> Async<()> {
Async::Ready(())
}
fn read_vec(&mut self, bufs: &mut [&mut IoVec]) -> io::Result<usize> {
if bufs.is_empty() {
Ok(0)
} else {
self.read(&mut bufs[0])
}
}
fn write_vec(&mut self, bufs: &[&IoVec]) -> io::Result<usize> {
if bufs.is_empty() {
Ok(0)
} else {
self.write(&bufs[0])
}
}
fn framed<C: Codec>(self, codec: C) -> Framed<Self, C>
where Self: Sized,
{
frame::framed(self, codec)
}
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>)
where Self: Sized
{
split::split(self)
}
}
#[doc(hidden)]
#[deprecated(since = "0.1.1", note = "replaced by Sink + Stream")]
pub trait FramedIo {
type In;
type Out;
fn poll_read(&mut self) -> Async<()>;
fn read(&mut self) -> Poll<Self::Out, io::Error>;
fn poll_write(&mut self) -> Async<()>;
fn write(&mut self, req: Self::In) -> Poll<(), io::Error>;
fn flush(&mut self) -> Poll<(), io::Error>;
}