std IO & Formatting

This MOC maps the standard-library I/O and formatting surface: byte streams, buffered readers and writers, files, paths, format strings, specifiers, Display, and I/O errors.

What belongs here

This domain covers std::io, std::fmt, std::fs, and std::path as they are used together in ordinary Rust programs. It is about reading bytes, writing bytes, converting values to text, and naming filesystem locations. It is not a full operating-system programming map. It is not an async I/O map. It is not a serialization format map. It focuses on stable Rust edition 2024 / 1.85+. The core idea is simple: make I/O generic through traits, make text formatting compiler-checked, and make errors explicit.

Core notes

Reading path

Start with The Read and Write Traits. Then read Reading Standard Input and Writing Standard Output for terminal workflows. Move to O with BufReader and BufWriter once loops or large streams appear. Read Files in std::fs before doing real filesystem work. Read Path and PathBuf before designing any API that accepts paths. For user-facing text, start with Format Strings and format!. Then use Format Specifiers for layout and numeric output. Use Implementing Display by Hand when your own type needs {} output. Keep IO Errors and io::Result open while wiring these pieces together.

Patterns

Concepts

Antipatterns

Boundary decisions

Use Read and Write when the operation is about bytes. Use BufRead when the operation is about lines or delimiters. Use Path and PathBuf when the value is a filesystem path. Use format! when an owned String is the real result. Use write! or writeln! when the result should go directly to a writer. Use Display for a stable user-facing representation. Use Debug for developer diagnostics. Use io::Result<T> when the only error family is standard I/O. Use a richer application error type when I/O errors need domain context.

Sources