Module std::io

The io module contains basic input and output routines.

A quick summary:

Reader and Writer traits

These traits define the minimal set of methods that anything that can do input and output should implement.

ReaderUtil and WriterUtil traits

Richer methods that allow you to do more. Reader only lets you read a certain number of bytes into a buffer, while ReaderUtil allows you to read a whole line, for example.

Generally, these richer methods are probably the ones you want to actually use in day-to-day Rust.

Furthermore, because there is an implementation of ReaderUtil for <T: Reader>, when your input or output code implements Reader, you get all of these methods for free.

print and println

These very useful functions are defined here. You generally don't need to import them, though, as the prelude already does.

stdin, stdout, and stderr

These functions return references to the classic three file descriptors. They implement Reader and Writer, where appropriate.

Modules

fsync

Structs

BytesReader
BytesWriter
FILERes
FdRes

Enums

FileFlag
SeekStyle

The SeekStyle enum describes the relationship between the position we'd like to seek to from our current position. It's used as an argument to the seek method defined on the Reader trait.

WriterType

Traits

Reader

The core Reader trait. All readers must implement this trait.

ReaderUtil

The ReaderUtil trait is a home for many of the utility functions a particular Reader should implement.

Writer

The raw underlying writer trait. All writers must implement this.

WriterUtil

Generic utility functions defined on writers.

Functions

FILE_reader
FILE_writer
buffered_file_writer
fd_writer
file_reader
file_writer
mk_file_writer
print

Prints a string to standard output.

println

Prints a string to standard output, followed by a newline.

read_whole_file
read_whole_file_str
seek_in_buf
stderr

Gives a Writer which allows you to write to standard error.

stdin

Gives a Reader that allows you to read values from standard input.

stdout

Gives a Writer which allows you to write to the standard output.

u64_from_be_bytes
u64_to_be_bytes
u64_to_le_bytes
with_bytes_reader
with_bytes_writer
with_str_reader
with_str_writer

Type Definitions

fd_t