typeshift/lib.rs
1//! `typeshift` facade crate.
2//!
3//! This crate provides a Zod-like parse workflow using idiomatic Rust types.
4//! Use `#[typeshift]` on your struct or enum, then use:
5//! - [`parse_str`] for parse + validate
6//! - [`to_json`] for serialization
7//! - [`schema_json`] for JSON Schema export
8//!
9//! Many `#[validate(...)]` field attributes are reflected in schema output via
10//! `schemars` (such as `email`, `url`, `length`, `range`, and `regex`).
11//!
12//! # Example
13//!
14//! ```rust
15//! use typeshift::typeshift;
16//!
17//! #[typeshift]
18//! struct User {
19//! #[validate(length(min = 3))]
20//! name: String,
21//! }
22//!
23//! fn main() -> Result<(), Box<dyn std::error::Error>> {
24//! let user: User = typeshift::parse_str(r#"{"name":"Ada"}"#)?;
25//! let json = typeshift::to_json(&user)?;
26//! let schema = typeshift::schema_json::<User>();
27//!
28//! assert_eq!(json, r#"{"name":"Ada"}"#);
29//! assert_eq!(schema["type"], "object");
30//! Ok(())
31//! }
32//! ```
33
34/// Core trait and runtime helpers.
35pub use typeshift_core::*;
36
37/// Attribute macro that adds serde, validator, and schemars derives.
38pub use typeshift_derive::typeshift;
39
40/// Legacy compatibility derive.
41///
42/// This derive is a no-op compatibility marker. Prefer `#[typeshift]`.
43pub use typeshift_derive::TypeShift;