3 releases (breaking)
0.2.0 | Apr 2, 2023 |
---|---|
0.1.0 | Feb 5, 2023 |
0.0.1+alvr | Mar 21, 2022 |
#554 in Configuration
525 downloads per month
11KB
214 lines
settings-schema-rs
Derive macro for generating automatically a schema from Rust structures and enums. The schema can be serialized to JSON and/or used to generate a GUI.
Node types
- Section (from
struct
). Contains fields that can be marked as advanced setting. Unnamed fields are not supported. - Choice (from
enum
). Up to one unnamed field per variant is supported. Can be marked with thegui
attribute with"drop_down"
or"button_group"
. - Optional (from
Option
).None
is used when the content is "default" or calculated. - Switch. Can be
Enabled
(with data) orDisabled
. The content can be set to advanced. - Boolean (from
bool
). - Number (from
u/i 8/32/64/size
andf32/f64
). Attributegui
can betextbox
orslider
(with sub attribtesmin
,max
,step
andlogarithmic
). - Text (from
String
). - Array (from
[X; N]
). - Vector (from
Vec<X>
). - Dictionary (from
Vec<(String, X)>
).
Attributes like gui
can be applied to fields with compound types like Vec<Switch<u64>>
.
Custom types with generic type arguments are not supported.
New *Default
structures are automatically created to store default values. This is done to allow specifying the default data for all variants in a given enum.
Dependencies
~2–2.7MB
~61K SLoC