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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! # ModelStruct
//!
//! A Rust crate that provides a derive macro `Model` to automatically generate SQL `CREATE TABLE IF NOT EXISTS` statements from struct definitions.
//!
//! ## Features
//!
//! - **Automatic SQL Generation**: Derive the `Model` trait to generate SQL table creation statements
//! - **Type Safety**: Only supports a limited set of Rust types that can be safely mapped to SQL types
//! - **Nullable Support**: Handles `Option<T>` types as nullable columns
//! - **Simple API**: Just derive `Model` and call `create_table_sql()` or `table_name()`
//!
//! ## Supported Types
//!
//! | Rust Type | SQL Type | Notes |
//! |-----------|----------|-------|
//! | `i8`, `i16`, `i32` | `INTEGER` | 32-bit integers |
//! | `i64` | `BIGINT` | 64-bit integers |
//! | `u8`, `u16`, `u32` | `INTEGER` | Unsigned integers |
//! | `u64` | `BIGINT` | Unsigned 64-bit integers |
//! | `f32`, `f64` | `REAL` | Floating point numbers |
//! | `bool` | `BOOLEAN` | Boolean values |
//! | `String` | `TEXT` | String values |
//! | `str` | `TEXT` | String slices |
//! | `Option<T>` | `T NULL` | Nullable columns |
//!
//! ## Example
//!
//! ```rust
//! use modelstruct::Model;
//!
//! #[derive(Model)]
//! struct User {
//! id: i32,
//! name: String,
//! email: Option<String>,
//! age: Option<i32>,
//! is_active: bool,
//! }
//!
//! fn main() {
//! let sql = User::create_table_sql();
//! println!("{}", sql);
//! // Output:
//! // CREATE TABLE IF NOT EXISTS user (
//! // id INTEGER,
//! // name TEXT,
//! // email TEXT NULL,
//! // age INTEGER NULL,
//! // is_active BOOLEAN
//! // );
//! }
//! ```
// Re-export the Model trait
pub use Model;
// Re-export the derive macro from the separate crate
pub use *;
// Module containing the Model trait