#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

#1347 in Procedural macros

Download history 163/week @ 2023-12-27 1185/week @ 2024-01-03 1645/week @ 2024-01-10 888/week @ 2024-01-17 1742/week @ 2024-01-24 1329/week @ 2024-01-31 1885/week @ 2024-02-07 2261/week @ 2024-02-14 573/week @ 2024-02-21 1229/week @ 2024-02-28 1953/week @ 2024-03-06 1767/week @ 2024-03-13 1298/week @ 2024-03-20 1388/week @ 2024-03-27

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

~305–750KB
~18K SLoC