[][src]Struct buf_stream::BufStream

pub struct BufStream<S: Write> { /* 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.

Implementations

impl<S: Read + Write> BufStream<S>[src]

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

Notable traits for BufStream<S>

impl<S: Read + Write> Read for BufStream<S>impl<S: Read + Write> Write for BufStream<S>
[src]

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

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

Notable traits for BufStream<S>

impl<S: Read + Write> Read for BufStream<S>impl<S: Read + Write> Write for BufStream<S>
[src]

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

pub fn get_ref(&self) -> &S[src]

Gets a reference to the underlying stream.

pub fn get_mut(&mut self) -> &mut S[src]

Gets a mutable reference to the underlying stream.

Warning

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

pub fn into_inner(self) -> Result<S, IntoInnerError<BufStream<S>>>[src]

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>[src]

impl<S: Debug + Write> Debug for BufStream<S>[src]

impl<S: Read + Write> Read for BufStream<S>[src]

impl<S: Seek + Write> Seek for BufStream<S>[src]

impl<S: Read + Write> Write for BufStream<S>[src]

Auto Trait Implementations

impl<S> RefUnwindSafe for BufStream<S> where
    S: RefUnwindSafe

impl<S> Send for BufStream<S> where
    S: Send

impl<S> Sync for BufStream<S> where
    S: Sync

impl<S> Unpin for BufStream<S> where
    S: Unpin

impl<S> UnwindSafe for BufStream<S> where
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.