typeshift 0.2.1

Zod-like parse, validation, and JSON Schema flow for Rust types
Documentation
# typeshift

`typeshift` provides a Zod-like parse workflow with idiomatic Rust types.

The struct or enum is the single source of truth. With one derive, you get:

- `Serialize`
- `Deserialize`
- `Validate`
- `JsonSchema`

## Install

```toml
[dependencies]
typeshift = "0.2"
```

## Quick start

```rust
use typeshift::TypeShift;

#[derive(TypeShift)]
struct User {
    #[validate(length(min = 3))]
    name: String,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let user: User = typeshift::parse_str(r#"{"name":"Ada"}"#)?;
    let json = typeshift::to_json(&user)?;
    let schema = typeshift::schema_json::<User>();

    assert_eq!(json, r#"{"name":"Ada"}"#);
    assert_eq!(schema["type"], "object");
    Ok(())
}
```

## API

- `parse_str<T: TypeShift>(&str) -> Result<T, TypeShiftError>`
- `to_json<T: TypeShift>(&T) -> Result<String, serde_json::Error>`
- `schema_json<T: TypeShift>() -> serde_json::Value`

## Notes

- `#[derive(TypeShift)]` supports structs and enums, including generics.
- Unions are intentionally not supported.

## More examples

- `cargo run -p typeshift --example basic`
- `cargo run -p typeshift --example enum_tagged`
- `cargo run -p typeshift --example generic_envelope`