Fluorite
Generate Rust code from schemas specified by YAML.
Using fluorite in a Cargo Project
Please check the demo project for details. Add following dependencies first:
[]
= { = "1.0", = ["serde_derive"] }
= "0.1"
= "0.7"
[]
= "0.1"
Using fluorite_codegen in the build.rs to generate codes during the Cargo build process:
Instruct your project to include the generated codes, e.g. in your lib or main file:
Using fluorite as a CLI
$ fluorite --help
Generate Rust code from schemas specified by YAML.
Usage: fluorite <COMMAND>
Commands:
rust Generate Rust code
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
$ fluorite rust --help
Usage: fluorite rust [OPTIONS] --output <OUTPUT>
Options:
-i, --inputs <INPUTS> Input definition files
-o, --output <OUTPUT> Output directory
-s, --single-file Output codes to a single mod file for each package
-h, --help Print help
Features
- Supports Yaml schema definition, see example here
- A codegen binary program
- Language Support
- Rust codegen used in Cargo
build.rsscript - TypeScript codegen
- CodeGen API to add more language supports to
fluorite
- Rust codegen used in Cargo
Schema Definition Features
More details can be found in definitions.rs.
- User defined types:
- Object
- Enum
- Union: to support polymorphic types during serialization/deserialization
- Collection types:
- List
- Map
- Primitive types
- String
- Bool
- DateTime
- UIntX
- IntX
- Float
- Optional fields support
- Any type fields support
Development
Make Commands
| Command | Description |
|---|---|
make all |
Run format check, lint, and tests |
make build |
Build the project |
make release |
Build in release mode |
make test |
Run all tests |
make fmt |
Format code |
make fmt-check |
Check code formatting |
make lint |
Run clippy lints |
make check |
Run cargo check |
make clean |
Clean build artifacts |