Struct tk_bufstream::IoBuf
[−]
[src]
pub struct IoBuf<S: Io> {
pub in_buf: Buf,
pub out_buf: Buf,
// some fields omitted
}A wrapper for full-duplex stream
Fields
in_buf: Buf
out_buf: Buf
Methods
impl<S: Io> IoBuf<S>[src]
Main trait of a stream (meaning socket) with input and output buffers
This is ought to be similar to tokio_core::Io but with buffers
fn new(sock: S) -> IoBuf<S>
Create a new IoBuf object with empty buffers
fn read(&mut self) -> Result<usize, Error>
Read a chunk of data into a buffer
The data just read can then be found in self.in_buf.
This method does just one read. Because you are ought to try parse request after every read rather than reading a lot of the data in memory.
This method returns 0 when no bytes are read, both when WouldBlock
occurred and when connection has been closed. You may then use
self.done() to distinguish from these conditions.
fn flush(&mut self) -> Result<(), Error>
Write data in the output buffer to actual stream
You should put the data to be sent into self.out_buf before flush
fn done(&self) -> bool
Returns true when connection is closed by peer
fn flushed(self) -> Flushed<S>
Returns a future which resolves to this stream when output buffer is flushed
Trait Implementations
impl<S: AsRawFd + Io> AsRawFd for IoBuf<S>[src]
impl<S: Io> Write for IoBuf<S>[src]
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<(), Error>
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 Self1.0.0
Creates a "by reference" adaptor for this instance of Write. Read more