Struct bufstream::BufStream [] [src]

pub struct BufStream<S: Write> {
    // some fields omitted
}

Wraps a Stream and buffers input and output to and from it.

It can be excessively inefficient to work directly with a Read+Write. For example, every call to read or write on TcpStream results in a system call. A BufStream keeps in memory buffers of data, making large, infrequent calls to read and write on the underlying Read+Write.

The output buffer will be written out when this stream is dropped.

Methods

impl<S: Read + Write> BufStream<S>

fn with_capacities(reader_cap: usize, writer_cap: usize, inner: S) -> BufStream<S>

Creates a new buffered stream with explicitly listed capacities for the reader/writer buffer.

fn new(inner: S) -> BufStream<S>

Creates a new buffered stream with the default reader/writer buffer capacities.

fn get_ref(&self) -> &S

Gets a reference to the underlying stream.

fn get_mut(&mut self) -> &mut S

Gets a mutable reference to the underlying stream.

Warning

It is inadvisable to read directly from or write directly to the underlying stream.

fn into_inner(self) -> Result<S, IntoInnerError<BufStream<S>>>

Unwraps this BufStream, returning the underlying stream.

The internal write buffer is written out before returning the stream. Any leftover data in the read buffer is lost.

Trait Implementations

impl<S: Read + Write> BufRead for BufStream<S>

fn fill_buf(&mut self) -> Result<&[u8]>

fn consume(&mut self, amt: usize)

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, Error>

fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>

fn split(self, byte: u8) -> Split<Self>

fn lines(self) -> Lines<Self>

impl<S: Read + Write> Read for BufStream<S>

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

fn by_ref(&mut self) -> &mut Self

fn bytes(self) -> Bytes<Self>

fn chars(self) -> Chars<Self>

fn chain<R>(self, next: R) -> Chain<Self, R> where R: Read

fn take(self, limit: u64) -> Take<Self>

fn tee<W>(self, out: W) -> Tee<Self, W> where W: Write

impl<S: Read + Write> Write for BufStream<S>

fn write(&mut self, buf: &[u8]) -> Result<usize>

fn flush(&mut self) -> Result<()>

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>

fn by_ref(&mut self) -> &mut Self

fn broadcast<W>(self, other: W) -> Broadcast<Self, W> where W: Write

Derived Implementations

impl<S: Debug + Write> Debug for BufStream<S>

fn fmt(&self, __arg_0: &mut Formatter) -> Result