1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! `typeshift` facade crate.
//!
//! This crate provides a Zod-like parse workflow using idiomatic Rust types.
//! Use `#[typeshift]` on your struct or enum, then use:
//! - [`parse_str`] for parse + validate
//! - [`to_json`] for serialization
//! - [`schema_json`] for JSON Schema export
//!
//! Many `#[validate(...)]` field attributes are reflected in schema output via
//! `schemars` (such as `email`, `url`, `length`, `range`, and `regex`).
//!
//! # Example
//!
//! ```rust
//! use typeshift::typeshift;
//!
//! #[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(())
//! }
//! ```
/// Core trait and runtime helpers.
pub use *;
/// Attribute macro that adds serde, validator, and schemars derives.
pub use typeshift;
/// Legacy compatibility derive.
///
/// This derive is a no-op compatibility marker. Prefer `#[typeshift]`.
pub use TypeShift;