RTK is a tool for querying Rust codebases to extract accurate type information and emit types in other programming languages.
- Generate OpenAPI or TypeScript bindings directly from Axum server code.
- Statically check SQL query types or generate Rust types based on SQL schemas.
- Create typed APIs for Lua engines embedded within Rust applications.
RTK itself uses this mechanism for its Lua API.
- Accurate and complete type inference via rustc.
- No modification of source code, macros or dependencies required.
- Emission scripts are written in Lua full control targeted specifically to your project.
Currently, RTK supports querying:
- Method calls by definition path.
- Function calls and definitions by path.
- Trait implementations and associated functions.
RTK resolves all required type dependencies recursively, including:
- Proc macro attributes (e.g. serde annotations).
- Async return types.
- Struct field names.
- Enum variants and associated data.
- Common Rust primitives and standard library types (Option, HashMap, Result, etc.).
Examples and the Lua API can be found in the examples directory and the Lua API definition file.
RTK is in early development. Documentation is limited, and certain features such as generic parameters and extended standard types may be incomplete. Review the generated Lua API in lua/rtk_api.lua for the most accurate reference.
Contributions are encouraged; the codebase is fairly slim and approachable for new contributors.
Navigate to your Rust project and create a Lua script:
Use the examples/axum-to-ts/rtk.lua file as a reference template. Ensure the Lua script specifies the RTK API version:
Run RTK:
RTK writes emitted results to the specified output file.
Given this Axum setup:
The corresponding RTK Lua script to generate TypeScript bindings:
This generates:
Refer to examples/axum-to-ts for the complete demonstration.
.png)

