#axum #wasm #cloudflare #browser

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

#1908 in Procedural macros

Download history 16/week @ 2023-10-18 15/week @ 2023-10-25 13/week @ 2023-11-01 15/week @ 2023-11-08 23/week @ 2023-11-15 23/week @ 2023-11-22 63/week @ 2023-11-29 9/week @ 2023-12-06 12/week @ 2023-12-13 11/week @ 2023-12-20 213/week @ 2023-12-27 1320/week @ 2024-01-03 1789/week @ 2024-01-10 966/week @ 2024-01-17 1876/week @ 2024-01-24 1446/week @ 2024-01-31

6,418 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

~320–760KB
~18K SLoC