oxa-types

Crates.iooxa-types
lib.rsoxa-types
version0.1.0
created_at2025-12-23 23:13:36.144573+00
updated_at2025-12-24 02:25:42.692447+00
descriptionRust types generated from the OXA schema
homepage
repositoryhttps://github.com/oxa-dev/oxa
max_upload_size
id2002513
size10,621
Nokome Bentley (nokome)

documentation

README

oxa-types

Rust types generated from the OXA schema.

Installation

Add this to your Cargo.toml:

[dependencies]
oxa-types = "0.1"

Usage

use oxa_types::{Document, Block, Paragraph, Inline, Text};

fn main() {
    // Parse from JSON
    let json = r#"{
        "type": "Document",
        "metadata": {},
        "title": [],
        "children": [
            {
                "type": "Paragraph",
                "classes": [],
                "data": {},
                "children": [
                    {"type": "Text", "classes": [], "data": {}, "value": "Hello, world!"}
                ]
            }
        ]
    }"#;

    let doc: Document = serde_json::from_str(json).unwrap();
    println!("{:?}", doc);

    // Serialize back to JSON
    let output = serde_json::to_string_pretty(&doc).unwrap();
    println!("{}", output);
}

The type field uses monostate::MustBe! to ensure type-safe deserialization - each struct only accepts its specific type value.

Development

The types in this crate are auto-generated from the OXA JSON Schema. Do not edit src/lib.rs directly. Instead:

  1. Edit the YAML schema files in schema/
  2. Run pnpm codegen rs to regenerate the Rust types
Commit count: 0

cargo fmt