AFast
AFast is a high-performance asynchronous Rust web framework designed to simplify building networked applications. It supports multiple protocols via feature flags and provides automatic code generation for clients (TypeScript and JavaScript), API documentation, and field validation.
Instrutions
Supported Protocol Features
You can enable the following features in your Cargo.toml:
http- enable HTTP support/api- HTTP API endpoint/js- JavaScript client/ts- TypeScript client
ws- enable WebSocket support/ws- WebSocket endpoint
tcp- enable TCP support
Note on TCP usage:
If the tcp feature is enabled, the AFast::serve method takes two arguments:
- The TCP address to listen on (
"127.0.0.1:8080"). - The HTTP/WS address (
"127.0.0.1:8081") for web clients and generated JS/TS clients.
This allows you to run TCP and HTTP/WS servers simultaneously in the same application.
Key Features
- Automatic generation of TypeScript/JavaScript clients for your API
- Automatic generation of documentation
- Automatic field validation, including custom rules
- Async handler functions with state management
- Flexible multi-protocol support: HTTP, WS, TCP
Upcoming Features / Development Plan
- Nested structure validation for complex types
- Enable or disable js / ts / document by feautre flags
- Add command for generating client code
- Generate client code for additional languages: Java, Kotlin, C#, Rust, etc.
- Improved code generation templates for easier integration
- Enhanced error handling and validation reporting
Example
use ;
use ;
async
async
async