Trait tokio_core::io::Io
[−]
[src]
pub trait Io: Read + Write {
fn poll_read(&mut self) -> Async<()> { ... }
fn poll_write(&mut self) -> Async<()> { ... }
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where Self: Sized { ... }
}
A trait for read/write I/O objects
This trait represents I/O object which are readable and writable. Additionally, they're associated with the ability to test whether they're readable or writable.
Imporantly, the methods of this trait are intended to be used in conjuction with the current task of a future. Namely whenever any of them return a value that indicates "would block" the current future's task is arranged to receive a notification when the method would otherwise not indicate that it would block.
Provided Methods
fn poll_read(&mut self) -> Async<()>
Tests to see if this I/O object may be readable.
This method returns an Async<()>
indicating whether the object
might be readable. It is possible that even if this method returns
Async::Ready
that a call to read
would return a WouldBlock
error.
There is a default implementation for this function which always indicates that an I/O object is readable, but objects which can implement a finer grained version of this are recommended to do so.
If this function returns Async::NotReady
then the current future's
task is arranged to receive a notification when it might not return
NotReady
.
Panics
This method is likely to panic if called from outside the context of a future's task.
fn poll_write(&mut self) -> Async<()>
Tests to see if this I/O object may be writable.
This method returns an Async<()>
indicating whether the object
might be writable. It is possible that even if this method returns
Async::Ready
that a call to write
would return a WouldBlock
error.
There is a default implementation for this function which always indicates that an I/O object is writable, but objects which can implement a finer grained version of this are recommended to do so.
If this function returns Async::NotReady
then the current future's
task is arranged to receive a notification when it might not return
NotReady
.
Panics
This method is likely to panic if called from outside the context of a future's task.
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where Self: Sized
Helper method for splitting this read/write object into two halves.
The two halves returned implement the Read
and Write
traits,
respectively, but are only usable on the current task.
Panics
This method will panic if there is not currently an active future task.
Implementors
impl Io for TcpStream
impl<'a> Io for &'a TcpStream
impl<E: Read + Write> Io for PollEvented<E>
impl<'a, E> Io for &'a PollEvented<E> where &'a E: Read + Write