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 926/week @ 2024-07-05 1111/week @ 2024-07-12 397/week @ 2024-07-19 531/week @ 2024-07-26 1106/week @ 2024-08-02 865/week @ 2024-08-09 1134/week @ 2024-08-16 1037/week @ 2024-08-23 1451/week @ 2024-08-30 1259/week @ 2024-09-06 1207/week @ 2024-09-13 1230/week @ 2024-09-20 427/week @ 2024-09-27 647/week @ 2024-10-04 99/week @ 2024-10-11 620/week @ 2024-10-18

1,966 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

~265–720KB
~17K SLoC