Struct std::io::NullStream
A null stream (similar to /dev/null
).
It behaves as a file of infinite capacity for writing and an empty file for reading.
Methods
impl NullStream { ... }
-
fn new() -> NullStream
Creates a new null stream.
-
fn read(self: &mut NullStream, _buf: &mut [u8]) -> Result<usize>
Reads from the stream into a provided buffer.
If successful, returns the number of bytes read. This may be less than the size of the provided buffer.
-
fn read_exact(self: &mut NullStream, buf: &mut [u8]) -> Result<()>
Fills the provided buffer by reading from the stream.
If stream had less bytes available than the size of the buffer, this method will return an
Error::eof()
. -
fn read_to_end(self: &mut NullStream, _buf: &mut StringBuf) -> Result<usize>
Reads the entire stream into a
StringBuf
.If successful, returns the number of bytes that were read.
-
fn write(self: &mut NullStream, buf: &[u8]) -> Result<usize>
Write the buffer to the stream.
Returns the number of bytes written. This may be less than the size of the buffer. See also write_all, which can be used to write the entire buffer.
-
fn write_all(self: &mut NullStream, _buf: &[u8]) -> Result<()>
Writes all the bytes in the buffer to the stream.
If EOF is reached, returns
Error::eof()
. -
fn flush(self: &mut NullStream) -> Result<()>
Flush the stream
This may be a no-op, depending on the stream.