Skip to main content

Crate edlcodegen_macros

Crate edlcodegen_macros 

Source
Expand description

§edlcodegen-macros

This crate provides the procedural macros used by structs and enums generated from EDL definitions.

The macros automatically generates conversion code between the developer-facing EDL types and their corresponding generated target representations (e.g., schema-generated types used for serialization like FlatBuffers).

  • #[derive(EdlDerive)] together with #[target_struct(path::Type)] — generates impls for the core::convert::From trait to convert between an EDL-generated struct and its corresponding target struct type.

  • #[derive(EdlDerive)] together with #[target_enum(path::Type)] — generates impls for the core::convert::From trait to convert between an EDL-generated enum and its corresponding target enum type.

§Example

#[derive(EdlDerive)]
#[target_struct(GeneratedModule::NestedStructT)]
pub struct NestedStruct {
    pub id: u32,
    pub name: String,
    pub active: bool,
}

#[derive(EdlDerive)]
#[target_enum(GeneratedModule::Color)]
pub enum Color {
    Red,
    Green,
    Blue,
}

Derive Macros§

EdlDerive
Entry point for #[derive(EdlDerive)].