This project is a minimal prototype exploring multitier programming in Rust, inspired by Scala Loci. It demonstrates how to:
- Generate distributed RPC stubs at compile time using a procedural macro (
placement!) - Build and run separate client and server binaries using Rust features
- Communicate over HTTP/WebSockets (Axum + async channels)
The goal is to evaluate how Rust can support multitier code where remote calls look like normal function calls, and code placement (client vs server) is handled automatically at compile time.
The placement! macro expands at compile time and generates:
- Server-side RPC handler code
- Client-side stub functions that serialize and send RPC requests
The generated code is placed under:
target/generated
This prototype uses Rust features to build client and server binaries separately:
--features server→ Compiles server RPC handlers + starts Axum server--features client→ Compiles RPC stubs + WebSocket client
This ensures each binary only contains code relevant to its role.
❗ Features do not replace the procedural macro — they simply toggle build targets. The macro still does the RPC code generation.
multitier-app/
├── src/
│ ├── api.rs # RPC definitions + placement! macro usage
│ ├── client.rs # Client runtime & WebSocket RPC transport
│ ├── server.rs # Axum server, RPC execution
│ └── main.rs # Entry point (conditionally includes client or server)
├── target/generated/ # Auto-generated RPC stubs & handlers
├── run_server.sh # Clean + build + run server
├── run_client.sh # Clean + build + run client
└── Cargo.toml
├── placement_macros/ # Procedural macro crate
│ ├── Cargo.lock
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs # placement attribute macro implementation
./scripts/run_server.sh
Expected output:
Server running on localhost:3000
./scripts/run_client.sh
Expected output:
Connected
<remote function call results>
- Auto-generated code in
target/generated/
Potential improvements toward a generic distributed runtime:
- Multiple server/client nodes
- Dynamic node discovery & failure handling
- Typed ties / peer relations (like Scala Loci)
- Verification strategy (protocol + macro correctness)
This prototype is not a framework — it's a research scaffold to understand how Rust might support structured distributed programming with:
- Compile‑time placement checking
- Generated communication code
- Clean RPC ergonomics
- https://scala-loci.github.io/
- A Survey of Multitier Programming - PASCAL WEISENBURGER, JOHANNES WIRTH, and GUIDO SALVANESCHI, Technische Universität Darmstadt, Germany
- Distributed System Development with ScalaLoci - PASCAL WEISENBURGER, MIRKO KÖHLER, GUIDO SALVANESCHI, Technische Universität Darmstadt, Germany