mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
Migrate to using tokio-io
Deprecate the existing `io` module in this crate entirely. More details coming soon! Closes #61
This commit is contained in:
@@ -404,6 +404,11 @@ impl<T: Io, C: Codec> Sink for Framed<T, C> {
|
||||
trace!("framed transport flushed");
|
||||
return Ok(Async::Ready(()));
|
||||
}
|
||||
|
||||
fn close(&mut self) -> Poll<(), io::Error> {
|
||||
try_ready!(self.poll_complete());
|
||||
Ok(().into())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn framed<T, C>(io: T, codec: C) -> Framed<T, C> {
|
||||
|
||||
+7
-5
@@ -9,12 +9,14 @@
|
||||
//! [found online]: https://tokio.rs/docs/getting-started/core/
|
||||
//! [low level details]: https://tokio.rs/docs/going-deeper/core-low-level/
|
||||
|
||||
#![deprecated(note = "moved to the `tokio-io` crate")]
|
||||
|
||||
use std::io;
|
||||
|
||||
use futures::{BoxFuture, Async, Poll};
|
||||
use futures::{Async, Poll};
|
||||
use futures::future::BoxFuture;
|
||||
use futures::stream::BoxStream;
|
||||
|
||||
use mio::IoVec;
|
||||
use iovec::IoVec;
|
||||
|
||||
/// A convenience typedef around a `Future` whose error component is `io::Error`
|
||||
pub type IoFuture<T> = BoxFuture<T, io::Error>;
|
||||
@@ -138,7 +140,7 @@ pub trait Io: io::Read + io::Write {
|
||||
if bufs.is_empty() {
|
||||
Ok(0)
|
||||
} else {
|
||||
self.read(bufs[0].as_mut_bytes())
|
||||
self.read(&mut bufs[0])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +165,7 @@ pub trait Io: io::Read + io::Write {
|
||||
if bufs.is_empty() {
|
||||
Ok(0)
|
||||
} else {
|
||||
self.write(bufs[0].as_bytes())
|
||||
self.write(&bufs[0])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -2,7 +2,6 @@ use std::io::{self, Read, Write};
|
||||
|
||||
use futures::Async;
|
||||
use futures::sync::BiLock;
|
||||
use mio;
|
||||
|
||||
use io::Io;
|
||||
|
||||
@@ -47,7 +46,7 @@ impl<T: Read> Read for ReadHalf<T> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
match self.handle.poll_lock() {
|
||||
Async::Ready(mut l) => l.read(buf),
|
||||
Async::NotReady => Err(mio::would_block()),
|
||||
Async::NotReady => Err(::would_block()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,14 +55,14 @@ impl<T: Write> Write for WriteHalf<T> {
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
match self.handle.poll_lock() {
|
||||
Async::Ready(mut l) => l.write(buf),
|
||||
Async::NotReady => Err(mio::would_block()),
|
||||
Async::NotReady => Err(::would_block()),
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
match self.handle.poll_lock() {
|
||||
Async::Ready(mut l) => l.flush(),
|
||||
Async::NotReady => Err(mio::would_block()),
|
||||
Async::NotReady => Err(::would_block()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user