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
use TokenStream;
use quote;
/// Turns a serializable/deserializable struct into a microrm entity model.
///
/// There are two important visible effects:
/// - Provides an implementation of `microrm::entity::Entity`
/// - Defines a <struct-name>Columns enum
///
/// Note that names are converted from CamelCase to snake_case and vice versa
/// where applicable, so a struct named `TestModel` is given a table name `test_model`
/// and a struct field named `field_name` is given a variant name of `FieldName`.
///
/// The `#[microrm...]` attributes can be used to control the derivation somewhat.
/// The following are understood for the Entity struct:
/// - `#[microrm_internal]`: this is internal to the microrm crate (of extremely limited usefulness
/// outside the microrm library)
///
/// The following are understood on individual fields:
/// - `#[microrm_foreign]`: this is a foreign key (and the field must be of a type implementing `EntityID`)
/// Marks a struct or enum as able to be directly used in an Entity to correspond to a single database column.
/// Defines a struct to represent a optionally-unique index on a table.
///
/// Suppose the following `Entity` definition is used:
///
/// ```ignore
/// #[derive(Entity,Serialize,Deserialize)]
/// struct SystemUser {
/// username: String,
/// hashed_password: String
/// }
/// ```
///
/// We can now use `make_index!` to define an index on the username field:
/// ```ignore
/// make_index!(SystemUsernameIndex, SystemUserColumns::Username)
/// ```
///
/// This index can be made unique by adding a `!` prior to the type name, as:
/// ```ignore
/// make_index!(!SystemUsernameUniqueIndex, SystemUserColumns::Username)
/// ```
/// For internal use inside the microrm library. See `make_index`.
/*#[proc_macro]
pub fn query(tokens: TokenStream) -> TokenStream {
query::do_query(tokens)
}
*/