#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

#1477 in Procedural macros

Download history 1740/week @ 2024-01-09 873/week @ 2024-01-16 1703/week @ 2024-01-23 1441/week @ 2024-01-30 1776/week @ 2024-02-06 2286/week @ 2024-02-13 670/week @ 2024-02-20 1240/week @ 2024-02-27 1639/week @ 2024-03-05 1903/week @ 2024-03-12 1345/week @ 2024-03-19 1497/week @ 2024-03-26 2310/week @ 2024-04-02 1667/week @ 2024-04-09 2651/week @ 2024-04-16 1727/week @ 2024-04-23

8,625 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–720KB
~17K SLoC