pub trait IoExt {
Show 13 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<()>; 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§

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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§

Is to read_vectored what read_exact is to read.

Examples found in repository?
src/fs/file_io_ext.rs (line 521)
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
    fn read_exact_vectored_at(&self, bufs: &mut [IoSliceMut], offset: u64) -> io::Result<()> {
        // Similar to `read_vectored_at`, re-open the file so that we can do a seek and
        // leave the original file unmodified.
        let reopened = loop {
            match reopen(self) {
                Ok(file) => break file,
                Err(err) if err.kind() == io::ErrorKind::Interrupted => continue,
                Err(err) => return Err(err),
            }
        };
        loop {
            match reopened.seek(SeekFrom::Start(offset)) {
                Ok(_) => break,
                Err(err) if err.kind() == io::ErrorKind::Interrupted => continue,
                Err(err) => return Err(err),
            }
        }
        reopened.read_exact_vectored(bufs)
    }

Is to write_vectored what write_all is to write.

Examples found in repository?
src/fs/file_io_ext.rs (line 595)
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
    fn write_all_vectored_at(&self, bufs: &mut [IoSlice], offset: u64) -> io::Result<()> {
        // Similar to `read_vectored_at`, re-open the file to avoid adjusting
        // the current position of the already-open file.
        let reopened = loop {
            match reopen_write(self) {
                Ok(file) => break file,
                Err(err) if err.kind() == io::ErrorKind::Interrupted => continue,
                Err(err) => return Err(err),
            }
        };
        loop {
            match reopened.seek(SeekFrom::Start(offset)) {
                Ok(_) => break,
                Err(err) if err.kind() == io::ErrorKind::Interrupted => continue,
                Err(err) => return Err(err),
            }
        }
        reopened.write_all_vectored(bufs)
    }

Implementations on Foreign Types§

Implementors§