Struct tk_bufstream::IoBuf [] [src]

pub struct IoBuf<S> {
    pub in_buf: Buf,
    pub out_buf: Buf,
    // some fields omitted
}

A wrapper for full-duplex stream

Fields

Methods

impl<S> 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

Create a new IoBuf object with empty buffers

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.

Write data in the output buffer to actual stream

You should put the data to be sent into self.out_buf before flush

Returns true when connection is closed by peer

Returns a future which resolves to this stream when output buffer is flushed

Provides a Stream and Sink interface for reading and writing to this IoBuf object, using Decode and Encode to read and write the raw data.

Raw I/O objects work with byte sequences, but higher-level code usually wants to batch these into meaningful chunks, called "frames". This method layers framing on top of an I/O object, by using the Encode and Decode traits:

  • Encode interprets frames we want to send into bytes;
  • Decode interprets incoming bytes into a stream of frames.

Note that the incoming and outgoing frame types may be distinct.

This function returns a single object that is both Stream and Sink; grouping this into a single object is often useful for layering things like gzip or TLS, which require both read and write access to the underlying object.

If you want to work more directly with the streams and sink, consider calling split on the Framed returned by this method, which will break them into separate objects, allowing them to interact more easily.

Trait Implementations

impl<S> Debug for IoBuf<S>
[src]

Formats the value using the given formatter.

impl<S: AsRawFd> AsRawFd for IoBuf<S>
[src]

Extracts the raw file descriptor. Read more

impl<S: AsyncWrite> Write for IoBuf<S>
[src]

Write a buffer into this object, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Attempts to write an entire buffer into this write. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a "by reference" adaptor for this instance of Write. Read more