File tree Expand file tree Collapse file tree 1 file changed +3
-36
lines changed Expand file tree Collapse file tree 1 file changed +3
-36
lines changed Original file line number Diff line number Diff line change 11//! Async version of the Rust standard library.
22//!
33//! This crate is an async version of [`std`].
4+ //!
45//! Higher-level documentation in the form of the book
56//! ["Async programming in Rust with async-std"][book]
67//! is available.
2324//! }
2425//! ```
2526//!
26- //! Use sockets in a familiar way, with low-friction built-in timeouts:
27- //!
28- //! ```no_run
29- //! #![feature(async_await)]
30- //!
31- //! use std::time::Duration;
32- //!
33- //! use async_std::{
34- //! prelude::*,
35- //! task,
36- //! io,
37- //! net::TcpStream,
38- //! };
39- //!
40- //! async fn get() -> io::Result<Vec<u8>> {
41- //! let mut stream = TcpStream::connect("example.com:80").await?;
42- //! stream.write_all(b"GET /index.html HTTP/1.0\r\n\r\n").await?;
43- //!
44- //! let mut buf = vec![];
45- //!
46- //! io::timeout(Duration::from_secs(5), async {
47- //! stream.read_to_end(&mut buf).await?;
48- //! Ok(buf)
49- //! })
50- //! .await
51- //! }
52- //!
53- //! fn main() {
54- //! task::block_on(async {
55- //! let raw_response = get().await.expect("request");
56- //! let response = String::from_utf8(raw_response)
57- //! .expect("utf8 conversion");
58- //! println!("received: {}", response);
59- //! });
60- //! }
61- //! ```
27+ //! See [here](https://github.com/async-rs/async-std/tree/master/examples)
28+ //! for more examples.
6229
6330#![ feature( async_await) ]
6431#![ cfg_attr( feature = "docs" , feature( doc_cfg) ) ]
You can’t perform that action at this time.
0 commit comments