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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! All types valid as model fields and traits to make them valid.
//!
//! # Std types
//! - [`bool`]
//! - [`i16`]
//! - [`i32`]
//! - [`i64`]
//! - [`f32`]
//! - [`f64`]
//! - [`String`]
//! - [`Vec<u8>`]
//! - [`Option<T>`] where `T` is on this list
//!
//! # Our types
//! - [`ForeignModel<M>`](types::ForeignModel)
//! - [`BackRef<M>`](types::BackRef) (doesn't work inside an [`Option<T>`])
//! - [`Json<T>`](types::Json)
//! - [`MsgPack<T>`](types::MsgPack) (requires the "msgpack" feature)
//! - [`MaxStr`](types::MaxStr)
//!
//! # chrono types (requires the "chrono" feature)
//! - [`NaiveDateTime`](chrono::NaiveDateTime)
//! - [`NaiveTime`](chrono::NaiveTime)
//! - [`NaiveDate`](chrono::NaiveDate)
//! - [`DateTime<Utc>`](chrono::DateTime)
//!
//! # time types (requires the "time" feature)
//! - [`PrimitiveDateTime`](time::PrimitiveDateTime)
//! - [`Time`](time::Time)
//! - [`Date`](time::Date)
//! - [`OffsetDateTime<Utc>`](time::OffsetDateTime)
//!
//! # uuid types (requires the "uuid" feature)
//! - [`Uuid`](uuid::Uuid)
//!
//! # url types (requires the "url" feature)
//! - [`Url`](url::Url)
//!
//! ---
//!
//! ```no_run
//! use serde::{Deserialize, Serialize};
//! use rorm::{Model, field};
//! use rorm::fields::types::*;
//!
//! #[derive(Model)]
//! pub struct SomeModel {
//! #[rorm(id)]
//! id: i64,
//!
//! // std
//! boolean: bool,
//! integer: i32,
//! float: f64,
//! #[rorm(max_length = 255)]
//! string: String,
//! binary: Vec<u8>,
//!
//! // times
//! time: chrono::NaiveTime,
//! date: chrono::NaiveDate,
//! datetime: chrono::DateTime<chrono::Utc>,
//!
//! // relations
//! other_model: ForeignModel<OtherModel>,
//! also_other_model: ForeignModelByField<field!(OtherModel.name)>,
//! other_model_set: BackRef<field!(OtherModel.some_model)>,
//!
//! // serde
//! data: Json<Data>,
//! }
//!
//! #[derive(Model)]
//! pub struct OtherModel {
//! #[rorm(id)]
//! id: i64,
//!
//! #[rorm(max_length = 255)]
//! name: String,
//!
//! some_model: ForeignModel<SomeModel>,
//! }
//!
//! #[derive(Serialize, Deserialize)]
//! pub struct Data {
//! stuff: String,
//! }
//! ```