Struct tokio_core::reactor::PollEvented
[−]
[src]
pub struct PollEvented<E> { /* fields omitted */ }
A concrete implementation of a stream of readiness notifications for I/O objects that originates from an event loop.
Created by the PollEvented::new
method, each PollEvented
is
associated with a specific event loop and source of events that will be
registered with an event loop.
Each readiness stream has a number of methods to test whether the underlying
object is readable or writable. Once the methods return that an object is
readable/writable, then it will continue to do so until the need_read
or
need_write
methods are called.
That is, this object is typically wrapped in another form of I/O object. It's the responsibility of the wrapper to inform the readiness stream when a "would block" I/O event is seen. The readiness stream will then take care of any scheduling necessary to get notified when the event is ready again.
Methods
impl<E: Evented> PollEvented<E>
[src]
fn new(io: E, handle: &Handle) -> Result<PollEvented<E>>
Creates a new readiness stream associated with the provided
loop_handle
and for the given source
.
This method returns a future which will resolve to the readiness stream when it's ready.
impl<E> PollEvented<E>
[src]
fn poll_read(&self) -> Async<()>
Tests to see if this source is ready to be read from or not.
If this stream is not ready for a read then NotReady
will be returned
and the current task will be scheduled to receive a notification when
the stream is readable again. In other words, this method is only safe
to call from within the context of a future's task, typically done in a
Future::poll
method.
fn poll_write(&self) -> Async<()>
Tests to see if this source is ready to be written to or not.
If this stream is not ready for a write then NotReady
will be returned
and the current task will be scheduled to receive a notification when
the stream is writable again. In other words, this method is only safe
to call from within the context of a future's task, typically done in a
Future::poll
method.
fn need_read(&self)
Indicates to this source of events that the corresponding I/O object is no longer readable, but it needs to be.
This function, like poll_read
, is only safe to call from the context
of a future's task (typically in a Future::poll
implementation). It
informs this readiness stream that the underlying object is no longer
readable, typically because a "would block" error was seen.
The flag indicating that this stream is readable is unset and the current task is scheduled to receive a notification when the stream is then again readable.
fn need_write(&self)
Indicates to this source of events that the corresponding I/O object is no longer writable, but it needs to be.
This function, like poll_write
, is only safe to call from the context
of a future's task (typically in a Future::poll
implementation). It
informs this readiness stream that the underlying object is no longer
writable, typically because a "would block" error was seen.
The flag indicating that this stream is writable is unset and the current task is scheduled to receive a notification when the stream is then again writable.
fn remote(&self) -> &Remote
Returns a reference to the event loop handle that this readiness stream is associated with.
fn get_ref(&self) -> &E
Returns a shared reference to the underlying I/O object this readiness stream is wrapping.
fn get_mut(&mut self) -> &mut E
Returns a mutable reference to the underlying I/O object this readiness stream is wrapping.
Trait Implementations
impl<E: Read> Read for PollEvented<E>
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0
Read the exact number of bytes required to fill buf
. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Read
. Read more
fn bytes(self) -> Bytes<Self>
1.0.0
Transforms this Read
instance to an Iterator
over its bytes. Read more
fn chars(self) -> Chars<Self>
io
): the semantics of a partial read/write of where errors happen is currently unclear and may change
Transforms this Read
instance to an Iterator
over char
s. Read more
fn chain<R>(self, next: R) -> Chain<Self, R> where R: Read
1.0.0
Creates an adaptor which will chain this stream with another. Read more
fn take(self, limit: u64) -> Take<Self>
1.0.0
Creates an adaptor which will read at most limit
bytes from it. Read more
impl<E: Write> Write for PollEvented<E>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Write
. Read more
impl<E: Read + Write> Io for PollEvented<E>
[src]
fn poll_read(&mut self) -> Async<()>
Tests to see if this I/O object may be readable. Read more
fn poll_write(&mut self) -> Async<()>
Tests to see if this I/O object may be writable. Read more
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where Self: Sized
Helper method for splitting this read/write object into two halves. Read more
impl<'a, E> Read for &'a PollEvented<E> where &'a E: Read
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0
Read the exact number of bytes required to fill buf
. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Read
. Read more
fn bytes(self) -> Bytes<Self>
1.0.0
Transforms this Read
instance to an Iterator
over its bytes. Read more
fn chars(self) -> Chars<Self>
io
): the semantics of a partial read/write of where errors happen is currently unclear and may change
Transforms this Read
instance to an Iterator
over char
s. Read more
fn chain<R>(self, next: R) -> Chain<Self, R> where R: Read
1.0.0
Creates an adaptor which will chain this stream with another. Read more
fn take(self, limit: u64) -> Take<Self>
1.0.0
Creates an adaptor which will read at most limit
bytes from it. Read more
impl<'a, E> Write for &'a PollEvented<E> where &'a E: Write
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Write
. Read more
impl<'a, E> Io for &'a PollEvented<E> where &'a E: Read + Write
[src]
fn poll_read(&mut self) -> Async<()>
Tests to see if this I/O object may be readable. Read more
fn poll_write(&mut self) -> Async<()>
Tests to see if this I/O object may be writable. Read more
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where Self: Sized
Helper method for splitting this read/write object into two halves. Read more