Skip to main content

Crate germanic

Crate germanic 

Source
Expand description

§GERMANIC

Machine-readable schemas for websites.

§Architecture

┌─────────────────────────────────────────────────────────────────────────────┐
│                          GERMANIC ARCHITECTURE                              │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│    ┌─────────────┐      ┌─────────────┐      ┌─────────────┐               │
│    │   Schema    │      │   Compiler  │      │    .grm     │               │
│    │ (Rust + FB) │ ──→  │  (validate  │ ──→  │   File      │               │
│    │             │      │  + compile) │      │             │               │
│    └─────────────┘      └─────────────┘      └─────────────┘               │
│          │                    │                    │                       │
│          ▼                    ▼                    ▼                       │
│    ┌─────────────┐      ┌─────────────┐      ┌─────────────┐               │
│    │ JSON Input  │      │ Validation  │      │  Website    │               │
│    │ (from Plugin)      │ + Signature │      │ /data.grm   │               │
│    └─────────────┘      └─────────────┘      └─────────────┘               │
│                                                                             │
│    DATA FLOW: JSON → Rust Struct → FlatBuffer → .grm with Header           │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

§Usage

use germanic::GermanicSchema;
use serde::Deserialize;

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

fn main() {
    let json = r#"{"name": "Dr. Müller", "telefon": "+49 123 456"}"#;
    let practice: PracticeSchema = serde_json::from_str(json).unwrap();

    // Validation
    use germanic::schema::Validate;
    practice.validate().expect("Validation failed");
}

Modules§

compiler
Compilation from JSON to .grm.
dynamic
Dynamic compilation mode (Weg 3). Compiles JSON to .grm using runtime schema definitions.
error
Error types.
generated
Generated FlatBuffer bindings.
pre_validate
Pre-validation: schema-agnostic size and depth limits.
prelude
Commonly used items for easy import.
schema
Schema traits for metadata and validation.
schemas
Schema definitions (Rust structs with macro).
types
Header and .grm format.
validator
Validation of JSON against schema.

Derive Macros§

GermanicSchema
Re-export of the derive macro for easy use. Allows: use germanic::GermanicSchema;