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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
use ;
use proc_macro2 as pm2;
/// Derive the `Filterable` trait, creating suitable `FilterClass`
/// types.
///
/// This is only implemented for structs with named fields. All fields
/// will be exposed, with a default operator of `exact` unless annotated
/// to indicate otherwise. The annotations use the `django` attribute,
/// which has the following options:
///
/// - `#[django(rename="new_name")]` Expose the annotated member for
/// filtering as `new_name instead of using its name in the source
/// code.
///
/// - `#[django(default_op=iexact)]` Set the default operator, which
/// is applied when the field is referred to directly to be `iexact`,
/// where `iexact` can be replaced with any of the built-in operators
/// included in this crate.
///
/// - `#[django(default_fun=my_crate::MyOperatorClass)]` Set the
/// default operator to be the custom type
/// `my_crate::MyOperatorClass`, which must implement
/// `OperatorClass`.]
///
/// - `#[django(exclude)]` Do not expose this field, it cannot be used
/// in filtering.
///
/// - `#[django(traverse)]` This type of this field is itself `Filterable`
/// and nested filters onto its members are permitted via the double
/// underscore syntax that Django uses.
///
/// - `#[django(op(in, icontains))]` In addition to the default operator,
/// this field can also be filtered on using `in` and `icontains`, using
/// double underscores to separate the operator from the field name.
///
/// - `#[django(op(foo=my_crate::MyOperatorClass))]` This field has a
/// custom filter operator `foo` which can be appended to its name
/// with double underscores, and which when used, creates a filter
/// using `my_crate::MyOperatorClass`, which must itself be an
/// instance of `OperatorClass`.
/// Derive the `Sortable` trait, creating suitable `SorterClass` types.
///
/// This is only implemented for structs with named fields. No fields
/// will be available to use as sort orders, unless there are
/// annotations to indicate otherwise. The annotations use the
/// `django` attribute, which has the following significant options
/// here:
///
/// - `#[django(rename="new_name")]` Expose the annotated member for
/// sorting as `new_name instead of using its name in the source
/// code.
///
/// - `#[django(sort)]` The field, which must be [Ord], will be
/// exposed as a sort order for the enclosing type. The ordering
/// is taken directly from [Ord].
///
/// - `#[django(sort="name","age")]` The field has a type which is
/// itself `Sortable`. Expose this field as defining a sort order of
/// the same name, and When sorting by this field make the order
/// defined by the field's own member `name`, and then by its own
/// member `age` as a secondary sort.
/// Derive the `IntoRow` trait, determining the display of nested
/// objects.
///
/// This is only implemented for structs with named fields. All fields
/// will be included in the output by default, which means they must
/// have types which implement `IntoCellValue`. The annotations for
/// this derive macro use the `django` attribute, which has the
/// following significant options here:
///
/// - `#[django(rename="new_name")]` Expose the annotated member in
/// the output `new_name instead of using its name in the source code.
///
/// - `#[django(exclude)]` Do not include the annotated member in any
/// output.
///
/// - `#[django(foreign_key="field_name")]` The field has a type which
/// is itself `IntoRow`. Rather than requiring the field's type to
/// implement `IntoCellValue`, instead take the value of the field
/// from the cell called `field_name` in the field's own type's
/// output row.
/// Derive the `IntoRowWithContext` trait for `persian-rug` types.
///
/// This is only implemented for structs with named fields. All fields
/// will be included in the output by default, which means they must
/// have types which implement `IntoCellValue`. The annotations for
/// this derive macro use the `django` attribute, which has the
/// following significant options here:
///
/// - `#[django(rename="new_name")]` Expose the annotated member in
/// the output `new_name instead of using its name in the source code.
///
/// - `#[django(exclude)]` Do not include the annotated member in any
/// output.
///
/// - `#[django(foreign_key="field_name")]` The field has a type which
/// is itself `IntoRow`. Rather than requiring the field's type to
/// implement `IntoCellValue`, instead take the value of the field
/// from the cell called `field_name` in the field's own type's
/// output row.
///
/// The struct itself must also be annotated with the `django`
/// attribute, which gives the `persian-rug` constraints to apply to
/// to each derived `impl`:
///
/// - `#[django(persian_rug(context=Rug))]` The persian-rug
/// context type for this type is `Rug`.
///
/// - `#[django(persian_rug(context=C, access(Foo<C>)))]` The
/// persian-rug context type is the template parameter `C`. The
/// context must provide access to `Foo<C>`.
/// Derive the `SortableWithContext` trait for `persian-rug` types.
///
/// This is only implemented for structs with named fields. No fields
/// will be available to use as sort orders, unless there are
/// annotations to indicate otherwise. The annotations use the
/// `django` attribute, which has the following significant options
/// here:
///
/// - `#[django(rename="new_name")]` Expose the annotated member for
/// sorting as `new_name instead of using its name in the source
/// code.
///
/// - `#[django(sort)]` The field, which must be [Ord], will be
/// exposed as a sort order for the enclosing type. The ordering
/// is taken directly from [Ord].
///
/// - `#[django(sort="name","age")]` The field has a type which is
/// itself `Sortable`. Expose this field as defining a sort order of
/// the same name, and When sorting by this field make the order
/// defined by the field's own member `name`, and then by its own
/// member `age` as a secondary sort.
///
/// The struct itself must also be annotated with the `django`
/// attribute, which gives the `persian-rug` constraints to apply to
/// to each derived `impl`:
///
/// - `#[django(persian_rug(context=Rug))]` The persian-rug
/// context type for this type is `Rug`.
///
/// - `#[django(persian_rug(context=C, access(Foo<C>)))]` The
/// persian-rug context type is the template parameter `C`. The
/// context must provide access to `Foo<C>`.
/// Derive the `FilterableWithContext` trait for `persian-rug` types.
///
/// This is only implemented for structs with named fields. All fields
/// will be exposed, with a default operator of `exact` unless annotated
/// to indicate otherwise. The field annotations use the `django` attribute,
/// which has the following options:
///
/// - `#[django(rename="new_name")]` Expose the annotated member for
/// filtering as `new_name instead of using its name in the source
/// code.
///
/// - `#[django(default_op=iexact)]` Set the default operator, which
/// is applied when the field is referred to directly to be `iexact`,
/// where `iexact` can be replaced with any of the built-in operators
/// included in `django-query`.
///
/// - `#[django(default_fun=my_crate::MyOperatorClass)]` Set the
/// default operator to be the custom type
/// `my_crate::MyOperatorClass`, which must implement
/// `OperatorClass`.
///
/// - `#[django(exclude)]` Do not expose this field, it cannot be used
/// in filtering.
///
/// - `#[django(traverse)]` This type of this field is itself `Filterable`
/// and nested filters onto its members are permitted via the double
/// underscore syntax that Django uses.
///
/// - `#[django(op(in, icontains))]` In addition to the default operator,
/// this field can also be filtered on using `in` and `icontains`, using
/// double underscores to separate the operator from the field name.
///
/// - `#[django(op(foo=my_crate::MyOperatorClass))]` This field has a
/// custom filter operator `foo` which can be appended to its name
/// with double underscores, and which when used, creates a filter
/// using `my_crate::MyOperatorClass`, which must itself be an
/// instance of `OperatorClass`.
///
/// The struct itself must also be annotated with the `django`
/// attribute, which gives the `persian-rug` constraints to apply to
/// to each derived `impl`:
///
/// - `#[django(persian_rug(context=Rug))]` The persian-rug
/// context type for this type is `Rug`.
///
/// - `#[django(persian_rug(context=C, access(Foo<C>)))]` The
/// persian-rug context type is the template parameter `C`. The
/// context must provide access to `Foo<C>`.