Skip to main content

Crate germanic_macros

Crate germanic_macros 

Source
Expand description

§GERMANIC Macros

Proc-macro crate for the GERMANIC schema system.

§Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    MACRO PROCESSING PIPELINE                    │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│   Rust Source Code                                              │
│   ┌─────────────────────────────────────────┐                   │
│   │ #[derive(GermanicSchema)]               │                   │
│   │ #[germanic(schema_id = "...", ...)]     │                   │
│   │ pub struct PracticeSchema { ... }       │                   │
│   └─────────────────────────────────────────┘                   │
│                      │                                          │
│                      ▼                                          │
│   ┌─────────────────────────────────────────┐                   │
│   │           syn::parse()                  │                   │
│   │   Token Stream → DeriveInput (AST)      │                   │
│   └─────────────────────────────────────────┘                   │
│                      │                                          │
│                      ▼                                          │
│   ┌─────────────────────────────────────────┐                   │
│   │       darling::FromDeriveInput          │                   │
│   │   AST → SchemaOpts (typed data)         │                   │
│   └─────────────────────────────────────────┘                   │
│                      │                                          │
│                      ▼                                          │
│   ┌─────────────────────────────────────────┐                   │
│   │           quote::quote!()               │                   │
│   │   Typed Data → Rust Code                │                   │
│   └─────────────────────────────────────────┘                   │
│                      │                                          │
│                      ▼                                          │
│   Generated Rust Code                                           │
│   ┌─────────────────────────────────────────┐                   │
│   │ impl GermanicSerialize for PracticeSchema│                  │
│   │ impl SchemaMetadata for PracticeSchema  │                   │
│   │ impl Validate for PracticeSchema        │                   │
│   └─────────────────────────────────────────┘                   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

§Usage

use germanic_macros::GermanicSchema;

#[derive(GermanicSchema)]
#[germanic(schema_id = "de.gesundheit.praxis.v1")]
pub struct PracticeSchema {
    #[germanic(required)]
    pub name: String,

    pub telefon: Option<String>,
}

Derive Macros§

GermanicSchema
#[derive(GermanicSchema)]