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 1
1
//! Async version of the Rust standard library.
2
2
//!
3
3
//! This crate is an async version of [`std`].
4
+ //!
4
5
//! Higher-level documentation in the form of the book
5
6
//! ["Async programming in Rust with async-std"][book]
6
7
//! is available.
23
24
//! }
24
25
//! ```
25
26
//!
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.
62
29
63
30
#![ feature( async_await) ]
64
31
#![ cfg_attr( feature = "docs" , feature( doc_cfg) ) ]
You can’t perform that action at this time.
0 commit comments