diff --git a/docs/contribute/source/plugin/rusttls.md b/docs/contribute/source/plugin/rusttls.md index 6f8986f8..f7aa4b6f 100644 --- a/docs/contribute/source/plugin/rusttls.md +++ b/docs/contribute/source/plugin/rusttls.md @@ -2,7 +2,12 @@ sidebar_position: 8 --- -# Build with Rustls Plug-in +# (DEPRECATED after `0.14.0`) Build with Rustls Plug-in + + +:::note +This plug-in has been deprecated after WasmEdge `0.14.0` because the `rustls` is replaced by [`reqwest`](../../../develop/rust/http_service/client.md#the-reqwest-api). +::: The WasmEdge Rustls plug-in is a replacement for the OpenSSL plug-in in WasmEdge. It provides a Rust-friendly interface to the Rustls library, which is a modern, fast, and more secure alternative to OpenSSL. diff --git a/docs/develop/rust/database/my_sql_driver.md b/docs/develop/rust/database/my_sql_driver.md index 77f53ed1..7e550d34 100644 --- a/docs/develop/rust/database/my_sql_driver.md +++ b/docs/develop/rust/database/my_sql_driver.md @@ -45,7 +45,7 @@ wasmedge --env "DATABASE_SSL=1" --env "DATABASE_URL=mysql://user:passwd@mydb.123 In order to compile the `mysql_async` and `tokio` crates, we will need to apply two patches to add WasmEdge-specific socket APIs to those crates. The following example shows that the TLS connection is enabled. -``` +```toml [patch.crates-io] tokio = { git = "https://github.com/second-state/wasi_tokio.git", branch = "v1.36.x" } socket2 = { git = "https://github.com/second-state/socket2.git", branch = "v0.5.x" } @@ -63,7 +63,7 @@ statements. Connect to a MySQL database. -``` +```rust // Below we create a customized connection pool let opts = Opts::from_url(&*get_url()).unwrap(); let mut builder = OptsBuilder::from_opts(opts); @@ -80,7 +80,7 @@ Connect to a MySQL database. Create a table on the connected database. -``` +```rust // create table if no tables exist let result = r"SHOW TABLES LIKE 'orders';" .with(()) @@ -100,7 +100,7 @@ Create a table on the connected database. Insert some records into the MySQL database using SQL. -``` +```rust let orders = vec![ Order::new(1, 12, 2, 56.0, 15.0, 2.0, String::from("Mataderos 2312")), Order::new(2, 15, 3, 256.0, 30.0, 16.0, String::from("1234 NW Bobcat")), @@ -128,7 +128,7 @@ Insert some records into the MySQL database using SQL. Query the database. -``` +```rust // query data let loaded_orders = "SELECT * FROM orders" .with(()) @@ -153,8 +153,8 @@ Query the database. Delete some records from the database. -``` - // // delete some data +```rust + // delete some data r"DELETE FROM orders WHERE order_id=4;" .ignore(&mut conn) .await?; @@ -183,8 +183,8 @@ Delete some records from the database. Update records in the MySQL database. -``` - // // update some data +```rust + // update some data r"UPDATE orders SET shipping_address = '8366 Elizabeth St.' WHERE order_id = 2;" @@ -214,8 +214,7 @@ Update records in the MySQL database. Close the database connection. -``` +```rust drop(conn); pool.disconnect().await.unwrap(); ``` - diff --git a/docs/develop/rust/http_service/client.md b/docs/develop/rust/http_service/client.md index 49c5b65c..e58f32d7 100644 --- a/docs/develop/rust/http_service/client.md +++ b/docs/develop/rust/http_service/client.md @@ -110,7 +110,7 @@ wasmedge compile target/wasm32-wasi/release/wasmedge_hyper_client.wasm wasmedge_ wasmedge wasmedge_hyper_client.wasm ``` -In your Rust application, import the [hyper](https://crates.io/crates/hyper) crate, +In your Rust application, import the [hyper](https://crates.io/crates/hyper) crate, and patch it with WasmEdge sockets patches. Just add the following line to your `Cargo.toml`. @@ -139,7 +139,7 @@ wasmedge wasmedge_hyper_client_https.wasm In the HTTPS version of `Cargo.toml`, you just need to import the standard [hyper-rustls](https://crates.io/crates/hyper-rustls), [rustls](https://crates.io/crates/rustls) and [webpki-roots](https://crates.io/crates/webpki-roots) crates with the same patches as above. -``` +```toml [patch.crates-io] tokio = { git = "https://github.com/second-state/wasi_tokio.git", branch = "v1.36.x" } socket2 = { git = "https://github.com/second-state/socket2.git", branch = "v0.5.x" } @@ -212,4 +212,3 @@ async fn post_url_return_str (url: hyper::Uri, post_body: &'static [u8]) -> Resu Ok(()) } ``` - diff --git a/docs/develop/rust/setup.md b/docs/develop/rust/setup.md index 2047432c..2c00df8f 100644 --- a/docs/develop/rust/setup.md +++ b/docs/develop/rust/setup.md @@ -36,17 +36,16 @@ rustup target add wasm32-wasi ### Tokio support -WasmEdge supports async networking APIs provided by [Tokio](https://tokio.rs/) and related crates. If you have tokio in your `Cargo.toml`, you -need to add a few config flags to help the Rust compiler choose the correct feature branches in the library source code. Here is an example of `cargo build` command for -compiling a tokio app to Wasm. +WasmEdge supports async networking APIs provided by [Tokio](https://tokio.rs/) and related crates. If you have tokio in your `Cargo.toml`, you +need to add a few config flags to help the Rust compiler choose the correct feature branches in the library source code. Here is an example of `cargo build` command for compiling a tokio app to Wasm. -``` +```bash RUSTFLAGS="--cfg wasmedge --cfg tokio_unstable" cargo build --target wasm32-wasi --release ``` Alternatively, you could add these lines to the `.cargo/config.toml` file. -``` +```toml [build] target = "wasm32-wasi" rustflags = ["--cfg", "wasmedge", "--cfg", "tokio_unstable"] @@ -65,13 +64,12 @@ on MacOS, you need a special version of the Clang tool, released from the offici > When you compile Rust TLS source code to Wasm on Linux, the result Wasm file is cross-platform and can run correctly on any platform with WasmEdge installed. This section is only applicable when you need to **compile** Rust TLS source code on MacOS. -[Download the latest wasi-sdk release](https://github.com/WebAssembly/wasi-sdk/releases) for your platform and +[Download the latest wasi-sdk release](https://github.com/WebAssembly/wasi-sdk/releases) for your platform and expand it into a directory. Point the `WASI_SDK_PATH` variable to this directory and export a `CC` variable for the default Clang. -``` +```bash export WASI_SDK_PATH /path/to/wasi-sdk-22.0 export CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot" ``` That's it. Now you can use the `cargo` tools on MacOS to compile tokio libraries with `rust-tls` feature turned on. - diff --git a/docs/start/install.md b/docs/start/install.md index ae9ce18e..9a7ec518 100644 --- a/docs/start/install.md +++ b/docs/start/install.md @@ -254,7 +254,7 @@ curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/insta ### WasmEdge zlib Plug-in -The zlib is required for compiling and running many existing C / C++ / Rust apps in Wasm. Most noticeably, it is required for the Python port to Wasm. It supports the standard [zlib.h](https://github.com/madler/zlib/blob/develop/zlib.h) C API. +The zlib is required for compiling and running many existing C / C++ / Rust apps in Wasm. Most noticeably, it is required for the Python port to Wasm. It supports the standard [zlib.h](https://github.com/madler/zlib/blob/develop/zlib.h) C API. ```bash curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- --plugins wasmedge_zlib @@ -289,7 +289,6 @@ If you install this plug-in WITHOUT installer, you can [refer to here to install Then, go to [TensorFlow interface in Rust chapter](../develop/rust/wasinn/tf_plugin.md) to see how to run `WasmEdge-TensorFlow` functions. - ### TLS plug-in @@ -299,7 +298,7 @@ The WasmEdge TLS plugin is being deprecated from WasmEdge 0.14.0. We now compile The WasmEdge TLS plug-in utilizes the native OpenSSL library to support HTTPS and TLS requests from WasmEdge sockets. To install WasmEdge with the TLS plug-in, run the following command. -``` +```bash curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.13.5 --plugins wasmedge_rustls ``` diff --git a/docs/start/wasmedge/extensions/plugins.md b/docs/start/wasmedge/extensions/plugins.md index 910bc39b..c93a9b30 100644 --- a/docs/start/wasmedge/extensions/plugins.md +++ b/docs/start/wasmedge/extensions/plugins.md @@ -26,7 +26,7 @@ The following lists are the WasmEdge official released plug-ins. Users can insta | [WasmEdge-TensorflowLite](../../../contribute/source/plugin/tensorflowlite.md)| A native library for inferring TensorFlow-Lite models. | `manylinux2014 (x86_64, aarch64)`
`ubuntu 20.04 (x86_64)`
`darwin (x86_64, arm64)`
(since `0.13.0`) | [Rust](https://crates.io/crates/wasmedge_tensorflow_interface) (0.3.0) | [Steps](../../../contribute/source/plugin/tensorflowlite.md) | | WasmEdge-OpenCV | Very popular utility functions to process images and videos for AI input/output. | `manylinux2014 (x86_64, aarch64)`
`ubuntu 20.04 (x86_64)`
`darwin (x86_64, arm64)`
(since `0.13.3`) | Rust | | | [WasmEdge-eBPF](../../../contribute/source/plugin/ebpf.md) | A native library for inferring eBPF applications | `manylinux2014 (x86_64, aarch64)`
`ubuntu 20.04 (x86_64)`
(since `0.13.2`) | Rust | [Steps](../../../contribute/source/plugin/ebpf.md) | -| [WasmEdge-rustls](../../../contribute/source/plugin/rusttls.md) | A native library for inferring Rust and TLS Library | `manylinux2014 (x86_64, aarch64)`
`ubuntu 20.04 (x86_64)`
`darwin (x86_64, arm64)`
(since `0.13.0`) | [Rust](https://crates.io/crates/wasmedge_rustls_api) | [Steps](../../../contribute/source/plugin/rusttls.md) | +| [WasmEdge-rustls](../../../contribute/source/plugin/rusttls.md) (DEPRECATED) | A native library for inferring Rust and TLS Library | `manylinux2014 (x86_64, aarch64)`
`ubuntu 20.04 (x86_64)`
`darwin (x86_64, arm64)`
(since `0.13.0`, until `0.13.5`) | [Rust](https://crates.io/crates/wasmedge_rustls_api) | [Steps](../../../contribute/source/plugin/rusttls.md) | ## Old WasmEdge Extensions