Reflect To
- Generate type information in other languages based on rust types.
- Adhere to
serdeserialization behaviors whenever possible.
- Adhere to
- Builds upon a reusable rtti foundation in rust.
- Supported language type conversions:
- typescript via
typescriptflag (on by default) - python via
pythonflag- NOTE: Still an active WIP!
- typescript via
Typescript Example
By using the Reflect derive:
use Reflect;
use ;
use ;
the following type information can be generated at runtime (for instance as part of a wasm build process):
export interface User {
email: string;
isActive: boolean;
uploadedFiles: UserPost[];
profileImage: string | null;
settings: UserSettings;
status: UserStatus;
}
export type UserStatus =
"Offline"
| { "Online": {
status: string;
} }
| { "Unknown": string }
export interface UserPost {
post_name: string | null;
contents: string[];
}
export interface UserSettings {
themePath: string
emailNotifications: boolean
custom: Record<string, string>;
}
Demo
Run one of the examples via
cargo run --example to_python
or
cargo run --example to_typescript
Documentation
For now, the best documentation is the typescript and python examples.