Skip to content

Commit 52aa039

Browse files
committed
Add tokio note to lib.rs
(cherry picked from commit cf19438)
1 parent b658d7f commit 52aa039

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

elasticsearch/src/lib.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,38 @@
5151
//! serde = "~1"
5252
//! serde_json = "~1"
5353
//! ```
54+
//!
55+
//! ### Async support with tokio
56+
//!
57+
//! The client uses [`reqwest`](https://crates.io/crates/reqwest) to make HTTP calls, which internally uses
58+
//! the [`tokio`](https://crates.io/crates/tokio) runtime for async support. As such, you may require
59+
//! to take a dependency on `tokio` in order to use the client. For example, in Cargo.toml, you may
60+
//! need the following dependency
61+
//!
62+
//! ```toml,norun
63+
//! tokio = { version = "*", features = ["full"] }
64+
//! ```
65+
//!
66+
//! and to attribute async main function with `#[tokio::main]`
67+
//!
68+
//! ```rust,norun
69+
//! #[tokio::main]
70+
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
71+
//! // your code ...
72+
//! Ok(())
73+
//! }
74+
//! ```
75+
//!
76+
//! and attribute test functions with `#[tokio::test]`
77+
//!
78+
//! ```rust,norun
79+
//! #[tokio::test]
80+
//! async fn my_test() -> Result<(), Box<dyn std::error::Error>> {
81+
//! // your code ...
82+
//! Ok(())
83+
//! }
84+
//! ```
85+
//!
5486
//! ## Create a client
5587
//!
5688
//! To create a client to make API calls to Elasticsearch running on `http://localhost:9200`

0 commit comments

Comments
 (0)