#axum #cloudflare #browser #wasm

axum-wasm-macros

一个宏,用于使Axum与WASM之间具有兼容性

3个版本

0.1.2 2023年9月9日
0.1.1 2023年7月19日
0.1.0 2023年7月19日

1505过程宏

Download history · Rust 包仓库 1767/week @ 2024-03-13 · Rust 包仓库 1298/week @ 2024-03-20 · Rust 包仓库 1413/week @ 2024-03-27 · Rust 包仓库 2473/week @ 2024-04-03 · Rust 包仓库 1663/week @ 2024-04-10 · Rust 包仓库 2844/week @ 2024-04-17 · Rust 包仓库 1590/week @ 2024-04-24 · Rust 包仓库 1764/week @ 2024-05-01 · Rust 包仓库 1352/week @ 2024-05-08 · Rust 包仓库 1883/week @ 2024-05-15 · Rust 包仓库 1945/week @ 2024-05-22 · Rust 包仓库 2062/week @ 2024-05-29 · Rust 包仓库 1405/week @ 2024-06-05 · Rust 包仓库 1784/week @ 2024-06-12 · Rust 包仓库 1026/week @ 2024-06-19 · Rust 包仓库 936/week @ 2024-06-26 · Rust 包仓库

每月下载量 5,502
用于 2 crates

MIT 许可证

5KB

axum-wasm-macros

Crates.io

一个宏,确保异步Axum路由可以编译为WASM

为什么?

Axum处理器返回一个 Send 将来。然而,JS类型不返回一个 Send 将来。 wasm_compat 将提供返回类型之间的兼容性。

示例

use axum_wasm_macros::wasm_compat;
use axum::Router;
use axum::routing::get;

#[wasm_compat]
pub async fn index() -> &'static str {
    "Hello World"
}

pub fn main() {
    let router: Router = Router::new().route("/", get(index));
    // rest of the app code goes here.
}

lib.rs:

Axum WASM宏

Axum处理器返回一个 Send 将来。然而,JS类型不返回一个 Send 将来。 wasm_compat 将提供返回类型之间的兼容性。

use axum_wasm_macros::wasm_compat;
use axum::Router;
use axum::routing::get;

#[wasm_compat]
pub async fn index() -> &'static str {
    "Hello World"
}

pub fn main() {
    let router: Router = Router::new().route("/", get(index));
    // rest of the app code goes here.
}

依赖关系

~280–730KB
~17K SLoC