You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend the #[webtau::command] macro system so that the same Rust game logic can be compiled and deployed to multiple execution backends — not just Tauri (desktop) and WASM (browser), but also:
This is perfect for "Tauri or browser?" but the real question games need answered is broader:
Main thread or worker?
Immediate command or async job?
Local-only or remote-capable?
Client authority or server authority?
Real-world production games built on gametau have already demonstrated this need concretely. A simulation-heavy game might need:
An authority service (standalone Axum) for heavy computation like route solving or physics
A game-state authority (SpacetimeDB) for economy, fleet, contracts, multiplayer
Local client (Tauri + WASM) for rendering and immediate interactions
All three consume the same core/ crate logic. The difference is the execution wrapper. That wrapping is exactly what the macro already does for two targets — this proposal extends it to more.
What the DX should look like
The command stays the same
#[webtau::command]fncompute_routes(state:&GameState,origin:BodyId,dest:BodyId) -> Vec<RouteOption>{// pure game logic — no framework dependencies
state.route_solver.find_routes(origin, dest)}
The existing __webtau_<name> pattern already isolates pure logic from framework glue. Each new backend is just another generate_* function in the proc macro that wraps the same inner function differently.
Machine-readable command manifest from macro metadata
Generated TypeScript client per backend
OpenAPI spec generation for the Axum surface
Non-goals
This is not a "send Rust anywhere magically" framework — each backend has real constraints
This does not replace the need for backend-specific configuration (Axum routes, SpacetimeDB schema, etc.)
This does not attempt to abstract away the difference between local and remote execution — that is a conscious architectural choice the developer makes
Production games built on gametau have already encountered the need for:
A separate Rust authority service (Axum) for computationally heavy work
SpacetimeDB as canonical game-state authority for economy, fleet, and multiplayer
Shared HTTP contract schemas consumed by both desktop and web clients
The same core/ crate powering local client logic and remote authority services
The recurring pattern across these projects is:
gametau should support one typed Rust capability with multiple execution targets — local or remote dispatch depending on target, cost, and authority needs.
Summary
Extend the
#[webtau::command]macro system so that the same Rust game logic can be compiled and deployed to multiple execution backends — not just Tauri (desktop) and WASM (browser), but also:The user writes their game logic once. A project-level target configuration controls which backends the macro generates code for.
Why this matters
Today
#[webtau::command]generates exactly twocfgbranches:This is perfect for "Tauri or browser?" but the real question games need answered is broader:
Real-world production games built on gametau have already demonstrated this need concretely. A simulation-heavy game might need:
All three consume the same
core/crate logic. The difference is the execution wrapper. That wrapping is exactly what the macro already does for two targets — this proposal extends it to more.What the DX should look like
The command stays the same
Project configuration selects targets
The macro generates backend-specific wrappers
For Axum (behind
cfg(feature = "webtau_axum")):For SpacetimeDB (behind
cfg(feature = "webtau_spacetimedb")):The inner function is always the same
The existing
__webtau_<name>pattern already isolates pure logic from framework glue. Each new backend is just anothergenerate_*function in the proc macro that wraps the same inner function differently.Architecture
The macro already has the right shape for this:
Each generator is gated on a cargo feature flag. If the feature is not enabled, no code is emitted.
What needs to change in the macro crate
generate_axum(),generate_stdb(), etc.serde_json, SpacetimeDB has its own serde, WASM usesserde_wasm_bindgenspawn_blockingor the macro can generate the async boundaryWhat needs to change in the webtau crate
axum,spacetimedb,tokiowasm_state!but for Axum AppState and SpacetimeDB ReducerContext)What needs to change on the TypeScript side
Relationship to the API-kind split (#156)
Issue #156 proposes separating
command/query/job/authorityas distinct API kinds. That work is complementary:Together they form a matrix:
A
commandmight target all four backends. Anauthorityprobably only targets Axum or SpacetimeDB. The kind informs which targets make sense.Implementation phases
Phase 1: Axum backend
generate_axum()to the proc macrowebtau_axumState<Arc<RwLock<T>>>extractionRouterregistration helperPhase 2: Target configuration
[webtau.targets]configuration surfacePhase 3: SpacetimeDB backend
generate_stdb()to the proc macrowebtau_spacetimedb#[spacetimedb::reducer]wrappersPhase 4: TypeScript provider adapters
Phase 5: Manifest + typed clients (#139)
Non-goals
Prior art and cross-references
In this repo
Motivation from downstream projects
Production games built on gametau have already encountered the need for:
core/crate powering local client logic and remote authority servicesThe recurring pattern across these projects is:
This issue is that concept made concrete.