RonSchema

Derive Macro RonSchema 

Source
#[derive(RonSchema)]
{
    // Attributes available to this derive:
    #[ron]
}
Expand description

Derive macro for generating RON schema definitions.

§Attributes

§Container attributes

  • #[ron(rename = "Name")] - Rename the type
  • #[ron(rename_all = "camelCase")] - Rename all fields

§Field attributes

  • #[ron(default)] - Mark field as optional (has a default value)
  • #[ron(flatten)] - Flatten nested struct fields into the parent
  • #[ron(skip)] - Skip this field in the schema
  • #[ron(rename = "name")] - Rename this field

§Schema Output

Schemas are written at runtime by calling write_schemas() on the type:

use ron2::schema::RonSchema;

// Write to a specific directory
Config::write_schemas(Some("./schemas"))?;

// Or use the default XDG location (~/.local/share/ron-schemas/)
Config::write_schemas(None)?;

Schema files are named by their fully-qualified type path: my_crate::config::Configmy_crate/config/Config.schema.ron