-
Book Overview & Buying
-
Table Of Contents
Rust for C++ Developers
By :
Now that we understand how to work with paths, handle errors, and perform simple reading and writing operations, we have yet to encounter the actual Rust IO API. First, we'll examine how to open files. Then, we'll dive into the fundamental I/O traits living in the std::io module that make up the API itself. We'll examine each of these traits in turn, and finally, we'll investigate ways that the Rust I/O API can be extended using the crate ecosystem.
Before we can read or write any data, we need an input source or an output destination. While memory buffers or network sockets can all serve this purpose, files are the most common, so working with them is a natural place to begin.
Before a file can be read from or written to, it must be opened. Most operating systems expose different ways to open files. Usually, opening for reading and opening for writing are the most common methods, but depending...