#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

#86 in #cloudflare

Download history 15/week @ 2024-11-13 17/week @ 2024-11-20 11/week @ 2024-11-27 12/week @ 2024-12-04 48/week @ 2024-12-11 13/week @ 2024-12-18 58/week @ 2025-01-01 4/week @ 2025-01-08 21/week @ 2025-01-15 19/week @ 2025-01-22 6/week @ 2025-01-29 29/week @ 2025-02-05 16/week @ 2025-02-12 13/week @ 2025-02-19 37/week @ 2025-02-26

97 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

~215–660KB
~16K SLoC