Trait system_interface::io::IoExt
source · pub trait IoExt {
Show 13 methods
// Required methods
fn read(&self, buf: &mut [u8]) -> Result<usize>;
fn read_exact(&self, buf: &mut [u8]) -> Result<()>;
fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>;
fn read_to_end(&self, buf: &mut Vec<u8>) -> Result<usize>;
fn read_to_string(&self, buf: &mut String) -> Result<usize>;
fn peek(&self, buf: &mut [u8]) -> Result<usize>;
fn write(&self, buf: &[u8]) -> Result<usize>;
fn write_all(&self, buf: &[u8]) -> Result<()>;
fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize>;
fn write_fmt(&self, fmt: Arguments<'_>) -> Result<()>;
fn flush(&self) -> Result<()>;
// Provided methods
fn read_exact_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<()> { ... }
fn write_all_vectored(&self, bufs: &mut [IoSlice<'_>]) -> Result<()> { ... }
}
Expand description
Extension trait for I/O handles that are exterior-mutable readable and writeable.
Required Methods§
sourcefn read(&self, buf: &mut [u8]) -> Result<usize>
fn read(&self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning how many bytes were read.
This is similar to std::io::Read::read
, except it takes self
by
immutable reference since the entire side effect is I/O.
sourcefn read_exact(&self, buf: &mut [u8]) -> Result<()>
fn read_exact(&self, buf: &mut [u8]) -> Result<()>
Read the exact number of bytes required to fill buf
.
This is similar to std::io::Read::read_exact
, except it takes
self
by immutable reference since the entire side effect is I/O.
sourcefn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
Like read
, except that it reads into a slice of buffers.
This is similar to std::io::Read::read_vectored
, except it takes
self
by immutable reference since the entire side effect is I/O.
sourcefn read_to_end(&self, buf: &mut Vec<u8>) -> Result<usize>
fn read_to_end(&self, buf: &mut Vec<u8>) -> Result<usize>
Read all bytes until EOF in this source, placing them into buf
.
This is similar to std::io::Read::read_to_end
, except it takes
self
by immutable reference since the entire side effect is I/O.
sourcefn read_to_string(&self, buf: &mut String) -> Result<usize>
fn read_to_string(&self, buf: &mut String) -> Result<usize>
Read all bytes until EOF in this source, appending them to buf
.
This is similar to std::io::Read::read_to_string
, except it takes
self
by immutable reference since the entire side effect is I/O.
sourcefn peek(&self, buf: &mut [u8]) -> Result<usize>
fn peek(&self, buf: &mut [u8]) -> Result<usize>
Read bytes from the current position without advancing the current position.
This is similar to crate::io::Peek::peek
, except it takes
self
by immutable reference since the entire side effect is I/O.
sourcefn write(&self, buf: &[u8]) -> Result<usize>
fn write(&self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written.
This is similar to std::io::Write::write
, except it takes self
by
immutable reference since the entire side effect is I/O.
sourcefn write_all(&self, buf: &[u8]) -> Result<()>
fn write_all(&self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this writer.
This is similar to std::io::Write::write_all
, except it takes
self
by immutable reference since the entire side effect is I/O.
sourcefn write_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize>
Like write
, except that it writes from a slice of buffers.
This is similar to std::io::Write::write_vectored
, except it takes
self
by immutable reference since the entire side effect is I/O.
sourcefn write_fmt(&self, fmt: Arguments<'_>) -> Result<()>
fn write_fmt(&self, fmt: Arguments<'_>) -> Result<()>
Writes a formatted string into this writer, returning any error encountered.
This is similar to std::io::Write::write_fmt
, except it takes
self
by immutable reference since the entire side effect is I/O.
sourcefn flush(&self) -> Result<()>
fn flush(&self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
This is similar to std::io::Write::flush
, except it takes self
by
immutable reference since the entire side effect is I/O.
Provided Methods§
sourcefn read_exact_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<()>
fn read_exact_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<()>
Is to read_vectored
what read_exact
is to read
.
sourcefn write_all_vectored(&self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&self, bufs: &mut [IoSlice<'_>]) -> Result<()>
Is to write_vectored
what write_all
is to write
.