macro axum-wasm-macros

A macro to enable compabatility between Axum and and WASM

3 releases

0.1.2 Sep 9, 2023
0.1.1 Jul 19, 2023
0.1.0 Jul 19, 2023
Download history 1039/week @ 2024-07-08 857/week @ 2024-07-15 433/week @ 2024-07-22 659/week @ 2024-07-29 1151/week @ 2024-08-05 694/week @ 2024-08-12 1251/week @ 2024-08-19 1327/week @ 2024-08-26 1382/week @ 2024-09-02 947/week @ 2024-09-09 1261/week @ 2024-09-16 1246/week @ 2024-09-23 294/week @ 2024-09-30 672/week @ 2024-10-07 73/week @ 2024-10-14 896/week @ 2024-10-21

1,940 downloads per month
Used in 2 crates

MIT license

5KB

axum-wasm-macros

Crates.io

A macro to ensure async axum routes can compile to WASM

Why?

Axum handlers return a Send future. However, JS types do not return a Send future. wasm_compat will provide compatability between the return types.

Example

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 Macros

Axum handlers return a Send future. However, JS types do not return a Send future. wasm_compat will provide compatability between the return types.

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.
}

Dependencies

~275–730KB
~18K SLoC