[][src]Module futures_lite::io

Tools and combinators for I/O.

Examples

Read a file line by line:

use blocking::{block_on, Unblock};
use futures_lite::*;
use std::fs::File;

fn main() -> io::Result<()> {
    block_on(async {
        let file = Unblock::new(File::open("a.txt")?);
        let reader = io::BufReader::new(file);
        let mut lines = reader.lines();

        while let Some(line) = lines.next().await {
            println!("{}", line?);
        }
        Ok(())
    })
}

Re-exports

pub use std::io::Error;
pub use std::io::ErrorKind;
pub use std::io::Result;
pub use std::io::SeekFrom;
pub use futures_io::AsyncBufRead;
pub use futures_io::AsyncRead;
pub use futures_io::AsyncSeek;
pub use futures_io::AsyncWrite;

Structs

BufReader

Adds buffering to a reader.

BufWriter

Adds buffering to a writer.

Bytes

Reader for the AsyncReadExt::bytes() method.

Chain

Reader for the AsyncReadExt::chain() method.

CloseFuture

Future for the AsyncWriteExt::close() method.

Cursor

Gives an in-memory buffer a cursor for reading and writing.

Empty

Reader for the empty() function.

FlushFuture

Future for the AsyncWriteExt::flush() method.

Lines

Stream for the AsyncBufReadExt::lines() method.

ReadExactFuture

Future for the AsyncReadExt::read_exact() method.

ReadFuture

Future for the AsyncReadExt::read() method.

ReadLineFuture

Future for the AsyncBufReadExt::read_line() method.

ReadToEndFuture

Future for the AsyncReadExt::read_to_end() method.

ReadToStringFuture

Future for the AsyncReadExt::read_to_string() method.

ReadUntilFuture

Future for the AsyncBufReadExt::read_until() method.

ReadVectoredFuture

Future for the AsyncReadExt::read_vectored() method.

Repeat

Reader for the repeat() function.

SeekFuture

Future for the AsyncSeekExt::seek() method.

Sink

Writer for the sink() function.

Split

Stream for the AsyncBufReadExt::split() method.

Take

Reader for the AsyncReadExt::take() method.

WriteAllFuture

Future for the AsyncWriteExt::write_all() method.

WriteFuture

Future for the AsyncWriteExt::write() method.

WriteVectoredFuture

Future for the AsyncWriteExt::write_vectored() method.

Traits

AsyncBufReadExt

Extension trait for AsyncBufRead.

AsyncReadExt

Extension trait for AsyncRead.

AsyncSeekExt

Extension trait for AsyncSeek.

AsyncWriteExt

Extension trait for AsyncWrite.

Functions

copy

Copies the entire contents of a reader into a writer.

empty

Creates an empty reader.

repeat

Creates an infinite reader that reads the same byte repeatedly.

sink

Creates a writer that consumes and drops all data.