11//! Contains types which model the JSON responses from tmc-server
22
3+ use chrono:: { DateTime , FixedOffset } ;
34use lazy_static:: lazy_static;
45use regex:: Regex ;
56use schemars:: JsonSchema ;
@@ -39,6 +40,7 @@ pub struct User {
3940 pub administrator : bool ,
4041}
4142
43+ /// Organization information.
4244#[ derive( Debug , Serialize , Deserialize , JsonSchema ) ]
4345pub struct Organization {
4446 pub name : String ,
@@ -48,6 +50,7 @@ pub struct Organization {
4850 pub pinned : bool ,
4951}
5052
53+ /// Information for a course.
5154#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
5255pub struct Course {
5356 pub id : usize ,
@@ -61,6 +64,7 @@ pub struct Course {
6164 pub spyware_urls : Vec < String > ,
6265}
6366
67+ /// Data for a course.
6468#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
6569pub struct CourseData {
6670 pub name : String ,
@@ -69,7 +73,7 @@ pub struct CourseData {
6973 pub cache_version : Option < usize > ,
7074 pub spreadsheet_key : Option < String > ,
7175 pub hidden_if_registered_after : Option < String > ,
72- pub refreshed_at : Option < String > ,
76+ pub refreshed_at : Option < DateTime < FixedOffset > > ,
7377 pub locked_exercise_points_visible : bool ,
7478 pub description : Option < String > ,
7579 pub paste_visibility : Option < String > ,
@@ -102,6 +106,7 @@ struct CourseDetailsInner {
102106 pub exercises : Vec < Exercise > ,
103107}
104108
109+ /// Details for a course.
105110#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
106111#[ serde( from = "CourseDetailsWrapper" ) ]
107112pub struct CourseDetails {
@@ -149,6 +154,7 @@ pub struct Exercise {
149154 pub solution_zip_url : Option < String > ,
150155}
151156
157+ /// Exercise for a course.
152158#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
153159pub struct CourseExercise {
154160 pub id : usize ,
@@ -195,9 +201,10 @@ pub struct AwardedPoint {
195201 user_id : usize ,
196202 submission_id : usize ,
197203 name : String ,
198- created_at : String ,
204+ created_at : DateTime < FixedOffset > ,
199205}
200206
207+ /// Details for an exercise.
201208#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
202209pub struct ExerciseDetails {
203210 pub course_name : String ,
@@ -219,22 +226,23 @@ pub struct ExercisesDetails {
219226 pub checksum : String ,
220227}
221228
229+ /// Exercise submission.
222230#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
223231pub struct Submission {
224232 pub id : usize ,
225233 pub user_id : usize ,
226234 pub pretest_error : Option < String > ,
227- pub created_at : String ,
235+ pub created_at : DateTime < FixedOffset > ,
228236 pub exercise_name : String ,
229237 pub course_id : usize ,
230238 pub processed : bool ,
231239 pub all_tests_passed : bool ,
232240 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 > > ,
236244 pub times_sent_to_sandbox : usize ,
237- pub processing_attempts_started_at : String ,
245+ pub processing_attempts_started_at : DateTime < FixedOffset > ,
238246 pub params_json : Option < String > ,
239247 pub requires_review : bool ,
240248 pub requests_review : bool ,
@@ -253,7 +261,7 @@ pub struct ExerciseSubmission {
253261 pub id : usize ,
254262 pub user_id : usize ,
255263 pub course_id : usize ,
256- pub created_at : String ,
264+ pub created_at : DateTime < FixedOffset > ,
257265 pub all_tests_passed : bool ,
258266 pub points : Option < String > ,
259267 pub submitted_zip_url : String ,
@@ -263,6 +271,7 @@ pub struct ExerciseSubmission {
263271 pub requests_review : bool ,
264272}
265273
274+ /// Exercise submission.
266275#[ derive( Debug , Deserialize , Serialize , JsonSchema , Clone ) ]
267276pub struct NewSubmission {
268277 pub show_submission_url : String ,
@@ -291,6 +300,7 @@ pub enum SandboxStatus {
291300 ProcessingOnSandbox ,
292301}
293302
303+ /// Finished submission.
294304#[ derive( Debug , Deserialize , Serialize , PartialEq , Eq , JsonSchema ) ]
295305pub struct SubmissionFinished {
296306 pub api_version : usize ,
@@ -328,6 +338,7 @@ pub enum SubmissionStatus {
328338 Hidden ,
329339}
330340
341+ /// Response to feedback.
331342#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
332343pub struct SubmissionFeedbackResponse {
333344 pub api_version : usize ,
@@ -419,6 +430,7 @@ impl<'de> Visitor<'de> for SubmissionFeedbackKindVisitor {
419430 }
420431}
421432
433+ /// Code review.
422434#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
423435pub struct Review {
424436 pub submission_id : String ,
@@ -431,10 +443,11 @@ pub struct Review {
431443 pub points_not_awarded : Vec < String > ,
432444 pub url : String ,
433445 pub update_url : String ,
434- pub created_at : String ,
446+ pub created_at : DateTime < FixedOffset > ,
435447 pub updated_at : String ,
436448}
437449
450+ /// Updated exercises.
438451#[ derive( Debug , Deserialize , Serialize , JsonSchema ) ]
439452pub struct UpdateResult {
440453 pub created : Vec < Exercise > ,
0 commit comments