#axum #cloudflare #browser #wasm

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

#1505 in Procedural macros

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

5,502 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

~280–730KB
~17K SLoC