Reflect To
- Generate type information in other languages based on rust types.
- Adhere to
serdeserialization behaviors whenever possible.
- Adhere to
- Core
reflect_tocrate to use rtti in rust. - Supported language types:
- typescript via
to_typescriptcrate - python via
to_pythoncrate
- 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 {
theme_path: string;
email_notifications: 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.