Skip to content
evenframe

Rust types as the source of truth

Evenframe reads the Rust structs and enums in your project and generates TypeScript types, SurrealDB schemas, validation, and mock data from them.

cargo install evenframe

src/profile.rs

rust
use evenframe::Evenframe;
use serde::Serialize;

#[derive(Debug, Clone, Serialize, Evenframe)]
pub struct Profile {
    #[morphs(trim)]
    #[validators(non_empty, max_length = 80)]
    pub display_name: String,
    #[validators(email)]
    pub email: String,
}

What it does

Type generation

Writes ArkType, Effect, and Macroforge definitions for your Rust structs and enums.

Schema synchronization

Compares your types with a SurrealDB database and applies the differences, or writes the SurrealQL without connecting.

Validation

Validators on a field run when Rust deserializes it, in the generated TypeScript, and as database assertions.

Mock data

Generates test records that satisfy your field types, relations, and validators.

Ways to use it

Each part works on its own. A project can use the derive at runtime, a build script for TypeScript, and the CLI for its database.

Derive only

Validated deserialization and runtime type information. No database or code generation.

Build script

Generate TypeScript and SurrealQL files on every cargo build.

CLI

Generate files, synchronize a live database, and create mock data.