1
1
//! Contains types which model the JSON responses from tmc-server
2
2
3
+ use chrono:: { DateTime , FixedOffset } ;
3
4
use lazy_static:: lazy_static;
4
5
use regex:: Regex ;
5
6
use schemars:: JsonSchema ;
@@ -39,6 +40,7 @@ pub struct User {
39
40
pub administrator : bool ,
40
41
}
41
42
43
+ /// Organization information.
42
44
#[ derive( Debug , Serialize , Deserialize , JsonSchema ) ]
43
45
pub struct Organization {
44
46
pub name : String ,
@@ -48,6 +50,7 @@ pub struct Organization {
48
50
pub pinned : bool ,
49
51
}
50
52
53
+ /// Information for a course.
51
54
#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
52
55
pub struct Course {
53
56
pub id : usize ,
@@ -61,6 +64,7 @@ pub struct Course {
61
64
pub spyware_urls : Vec < String > ,
62
65
}
63
66
67
+ /// Data for a course.
64
68
#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
65
69
pub struct CourseData {
66
70
pub name : String ,
@@ -69,7 +73,7 @@ pub struct CourseData {
69
73
pub cache_version : Option < usize > ,
70
74
pub spreadsheet_key : Option < String > ,
71
75
pub hidden_if_registered_after : Option < String > ,
72
- pub refreshed_at : Option < String > ,
76
+ pub refreshed_at : Option < DateTime < FixedOffset > > ,
73
77
pub locked_exercise_points_visible : bool ,
74
78
pub description : Option < String > ,
75
79
pub paste_visibility : Option < String > ,
@@ -102,6 +106,7 @@ struct CourseDetailsInner {
102
106
pub exercises : Vec < Exercise > ,
103
107
}
104
108
109
+ /// Details for a course.
105
110
#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
106
111
#[ serde( from = "CourseDetailsWrapper" ) ]
107
112
pub struct CourseDetails {
@@ -149,6 +154,7 @@ pub struct Exercise {
149
154
pub solution_zip_url : Option < String > ,
150
155
}
151
156
157
+ /// Exercise for a course.
152
158
#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
153
159
pub struct CourseExercise {
154
160
pub id : usize ,
@@ -195,9 +201,10 @@ pub struct AwardedPoint {
195
201
user_id : usize ,
196
202
submission_id : usize ,
197
203
name : String ,
198
- created_at : String ,
204
+ created_at : DateTime < FixedOffset > ,
199
205
}
200
206
207
+ /// Details for an exercise.
201
208
#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
202
209
pub struct ExerciseDetails {
203
210
pub course_name : String ,
@@ -219,22 +226,23 @@ pub struct ExercisesDetails {
219
226
pub checksum : String ,
220
227
}
221
228
229
+ /// Exercise submission.
222
230
#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
223
231
pub struct Submission {
224
232
pub id : usize ,
225
233
pub user_id : usize ,
226
234
pub pretest_error : Option < String > ,
227
- pub created_at : String ,
235
+ pub created_at : DateTime < FixedOffset > ,
228
236
pub exercise_name : String ,
229
237
pub course_id : usize ,
230
238
pub processed : bool ,
231
239
pub all_tests_passed : bool ,
232
240
pub points : Option < String > ,
233
- pub processing_tried_at : Option < String > ,
234
- pub processing_began_at : Option < String > ,
235
- pub processing_completed_at : Option < String > ,
241
+ pub processing_tried_at : Option < DateTime < FixedOffset > > ,
242
+ pub processing_began_at : Option < DateTime < FixedOffset > > ,
243
+ pub processing_completed_at : Option < DateTime < FixedOffset > > ,
236
244
pub times_sent_to_sandbox : usize ,
237
- pub processing_attempts_started_at : String ,
245
+ pub processing_attempts_started_at : DateTime < FixedOffset > ,
238
246
pub params_json : Option < String > ,
239
247
pub requires_review : bool ,
240
248
pub requests_review : bool ,
@@ -253,7 +261,7 @@ pub struct ExerciseSubmission {
253
261
pub id : usize ,
254
262
pub user_id : usize ,
255
263
pub course_id : usize ,
256
- pub created_at : String ,
264
+ pub created_at : DateTime < FixedOffset > ,
257
265
pub all_tests_passed : bool ,
258
266
pub points : Option < String > ,
259
267
pub submitted_zip_url : String ,
@@ -263,6 +271,7 @@ pub struct ExerciseSubmission {
263
271
pub requests_review : bool ,
264
272
}
265
273
274
+ /// Exercise submission.
266
275
#[ derive( Debug , Deserialize , Serialize , JsonSchema , Clone ) ]
267
276
pub struct NewSubmission {
268
277
pub show_submission_url : String ,
@@ -291,6 +300,7 @@ pub enum SandboxStatus {
291
300
ProcessingOnSandbox ,
292
301
}
293
302
303
+ /// Finished submission.
294
304
#[ derive( Debug , Deserialize , Serialize , PartialEq , Eq , JsonSchema ) ]
295
305
pub struct SubmissionFinished {
296
306
pub api_version : usize ,
@@ -328,6 +338,7 @@ pub enum SubmissionStatus {
328
338
Hidden ,
329
339
}
330
340
341
+ /// Response to feedback.
331
342
#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
332
343
pub struct SubmissionFeedbackResponse {
333
344
pub api_version : usize ,
@@ -419,6 +430,7 @@ impl<'de> Visitor<'de> for SubmissionFeedbackKindVisitor {
419
430
}
420
431
}
421
432
433
+ /// Code review.
422
434
#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
423
435
pub struct Review {
424
436
pub submission_id : String ,
@@ -431,10 +443,11 @@ pub struct Review {
431
443
pub points_not_awarded : Vec < String > ,
432
444
pub url : String ,
433
445
pub update_url : String ,
434
- pub created_at : String ,
446
+ pub created_at : DateTime < FixedOffset > ,
435
447
pub updated_at : String ,
436
448
}
437
449
450
+ /// Updated exercises.
438
451
#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
439
452
pub struct UpdateResult {
440
453
pub created : Vec < Exercise > ,
0 commit comments