You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/develop/rust/database/my_sql_driver.md
+14-1Lines changed: 14 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The database connection is necessary for today's enterprise development. WasmEdg
8
8
9
9
<!-- prettier-ignore -->
10
10
:::note
11
-
Before we start, ensure [you have Rust and WasmEdge installed](../setup.md).
11
+
Before we start, ensure [you have Rust and WasmEdge installed](../setup.md). If you are connecting to a remote MySQL database using TLS, you will need to [install the TLS plugin](../../../start/install.md#tls-plug-in) for WasmEdge as well.
Copy file name to clipboardExpand all lines: docs/develop/rust/http_service/client.md
+80-65Lines changed: 80 additions & 65 deletions
Original file line number
Diff line number
Diff line change
@@ -13,20 +13,95 @@ Before we start, ensure [you have Rust and WasmEdge installed](../setup.md). To
13
13
14
14
We will discuss HTTP and HTTPS clients using popular Rust APIs.
15
15
16
-
-[The hyper API (recommended)](#the-hyper-api)
17
-
-[The http_req API](#the-http_req-api)
18
16
-[The reqwest API](#the-reqwest-api)
17
+
-[The hyper API](#the-hyper-api)
18
+
-[The http_req API](#the-http_req-api)
19
19
20
-
## The hyper API
20
+
## The reqwest API
21
21
22
-
The [hyper crate](https://crates.io/crates/hyper) is a widely used Rust library to create HTTP and HTTPS networking applications. We recommend you use it in WasmEdge applications. A key feature of the `hyper`crate is that it is based on the `tokio`runtime, which supports asynchronous network connections. Asynchronous HTTP or HTTPS requests do not block the execution of the calling application. It allows an application to make multiple concurrent HTTP requests and to process responses as they are received. That enables high-performance networking applications in WasmEdge.
22
+
The `reqwest` crate is a popular Rust library to create asynchronous HTTP clients. It is built on top of the `hyper`and `tokio`APIs. Many developers find it easier to use. But perhaps more importantly, many existing Rust applications use `reqwest`, and you can make them work in WasmEdge by simply replacing the `reqwest` crate with `reqwest_wasi`! Build and run [the example](https://github.com/WasmEdge/wasmedge_reqwest_demo/) in WasmEdge as follows.
23
23
24
24
<!-- prettier-ignore -->
25
25
:::note
26
26
Non-blocking I/O means that the application program can keep multiple connections open simultaneously, and process data in and out of those connections as they come in. The program can either alternatingly poll those open connections or wait for incoming data to trigger async functions. That allows I/O intensive programs to run much faster, even in a single-threaded environment.
27
27
:::
28
28
29
-
Build and run [the hyper example](https://github.com/WasmEdge/wasmedge_hyper_demo/) in WasmEdge as follows.
In your Rust application, import [the WasmEdge adapted reqwest crate](https://crates.io/crates/reqwest_wasi), which uses a special version of single-threaded Tokio that is adapted for WebAssembly. Just add the following lines to your `Cargo.toml`.
47
+
48
+
```toml
49
+
[dependencies]
50
+
reqwest_wasi = { version = "0.11", features = ["json"] }
51
+
tokio_wasi = { version = "1.21", features = ["full"] }
52
+
```
53
+
54
+
The [example Rust code](https://github.com/WasmEdge/wasmedge_reqwest_demo/blob/main/src/http.rs) below shows an HTTP GET request.
Then, in `Cargo.toml`, you should enable the TLS feature.
94
+
95
+
```
96
+
reqwest_wasi = { version = "0.11", features = ["wasmedge-tls"] }
97
+
tokio_wasi = { version = "1", features = ["rt", "macros", "net", "time"] }
98
+
```
99
+
100
+
Then, you can just replace the URLs in the above examples from `http` and `https`. [See details here](https://github.com/WasmEdge/wasmedge_reqwest_demo/blob/main/src/https.rs).
101
+
102
+
## The hyper API
103
+
104
+
The [hyper crate](https://crates.io/crates/hyper) is a widely used Rust library to create HTTP and HTTPS networking applications for both clients and servers. A key feature of the `hyper` crate is that it is based on the `tokio` runtime, which supports asynchronous network connections. Asynchronous HTTP or HTTPS requests do not block the execution of the calling application. It allows an application to make multiple concurrent HTTP requests and to process responses as they are received. That enables high-performance networking applications in WasmEdge. Build and run [the hyper example](https://github.com/WasmEdge/wasmedge_hyper_demo/) in WasmEdge as follows.
The `reqwest` crate is another popular Rust library to create asynchronous HTTP clients. It is built on top of the `hyper` API. Many developers find it easier to use. But perhaps more importantly, many existing Rust applications use `reqwest`, and you can make them work in WasmEdge by simply replacing the `reqwest` crate with `reqwest_wasi`! Build and run [the example](https://github.com/WasmEdge/wasmedge_reqwest_demo/) in WasmEdge as follows.
177
-
178
-
<!-- prettier-ignore -->
179
-
:::note
180
-
Our current adaptation of [reqwest_wasi](https://github.com/wasmedge/reqwest) does not support HTTPS yet. You are welcome to contribute to the project!
In your Rust application, import [the WasmEdge adapted reqwest crate](https://crates.io/crates/reqwest_wasi), which uses a special version of single-threaded Tokio that is adapted for WebAssembly. Just add the following lines to your `Cargo.toml`.
197
-
198
-
```toml
199
-
[dependencies]
200
-
reqwest_wasi = { version = "0.11", features = ["json"] }
201
-
tokio_wasi = { version = "1.21", features = ["full"] }
202
-
```
203
-
204
-
The [example Rust code](https://github.com/WasmEdge/wasmedge_reqwest_demo/blob/main/src/main.rs) below shows an HTTP GET request.
0 commit comments