[−][src]Crate futures_lite
A lightweight async prelude.
This crate is a subset of futures that compiles an order of magnitude faster, fixes minor warts in its API, fills in some obvious gaps, and removes all unsafe code from it.
In short, this crate aims to be more enjoyable than futures but still fully compatible with it.
Examples
Connect to a HTTP website, make a GET request, and pipe the response to the standard output:
use async_net::TcpStream; use blocking::{block_on, Unblock}; use futures_lite::*; fn main() -> io::Result<()> { block_on(async { let mut stream = TcpStream::connect("example.com:80").await?; let req = b"GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n"; stream.write_all(req).await?; let mut stdout = Unblock::new(std::io::stdout()); io::copy(&stream, &mut stdout).await?; Ok(()) }) }
Re-exports
pub use std::future::Future; |
pub use futures_core::Stream; |
pub use futures_io::AsyncBufRead; |
pub use futures_io::AsyncRead; |
pub use futures_io::AsyncSeek; |
pub use futures_io::AsyncWrite; |
pub use crate::io::AsyncBufReadExt; |
pub use crate::io::AsyncReadExt; |
pub use crate::io::AsyncSeekExt; |
pub use crate::io::AsyncWriteExt; |
pub use crate::stream::StreamExt; |
Modules
future | Combinators for the |
io | Tools and combinators for I/O. |
stream | Combinators for the |
Macros
pin | Pins a variable of type |
ready | Unwraps |