Struct std::io::BufStream
[−]
[src]
pub struct BufStream<S: Write> {
// some fields omitted
}: unsure about semantics of buffering two directions, leading to issues like #17136
Wraps a Stream and buffers input and output to and from it.
It can be excessively inefficient to work directly with a Read+Write`Read+Write. For example, every call to`. For
example, every call to read`reador` or write`writeon` on TcpStream`TcpStreamresults in a system call. A` results in a system
call. A BufStream`BufStreamkeeps in memory buffers of data, making large, infrequent calls to` keeps in memory buffers of data, making large,
infrequent calls to read`readand` and write`writeon the underlying` on the underlying Read+Write`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>
: unsure about semantics of buffering two directions, leading to issues like #17136
Creates a new buffered stream with explicitly listed capacities for the reader/writer buffer.
fn new(inner: S) -> BufStream<S>
: unsure about semantics of buffering two directions, leading to issues like #17136
Creates a new buffered stream with the default reader/writer buffer capacities.
fn get_ref(&self) -> &S
: unsure about semantics of buffering two directions, leading to issues like #17136
Gets a reference to the underlying stream.
fn get_mut(&mut self) -> &mut S
: unsure about semantics of buffering two directions, leading to issues like #17136
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>>>
: unsure about semantics of buffering two directions, leading to issues like #17136
Unwraps this BufStream`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.