Skip to main content

librus_rs/structs/
events.rs

1//! Homework and event data types.
2
3use serde::Deserialize;
4
5/// Response containing all homeworks.
6#[derive(Debug, Deserialize)]
7#[serde(rename_all = "PascalCase")]
8pub struct ResponseHomeworks {
9    /// List of homework assignments.
10    #[serde(rename = "HomeWorks")]
11    pub homeworks: Vec<Homework>,
12    /// Related API resources.
13    pub resources: Option<HomeworksResources>,
14    /// API URL for this response.
15    pub url: String,
16}
17
18/// A homework assignment.
19#[derive(Debug, Deserialize)]
20#[serde(rename_all = "PascalCase")]
21pub struct Homework {
22    /// Unique homework identifier.
23    pub id: i64,
24    /// Homework content/description.
25    pub content: String,
26    /// Due date.
27    pub date: String,
28    /// Reference to the homework category.
29    pub category: HomeworksCategory,
30    /// Lesson number when assigned.
31    pub lesson_no: Option<String>,
32    /// Start time.
33    pub time_from: String,
34    /// End time.
35    pub time_to: String,
36    /// Reference to the teacher who created this homework.
37    pub created_by: HomeworksCategory,
38    /// Reference to the class.
39    pub class: Option<HomeworksCategory>,
40    /// Reference to the subject.
41    pub subject: Option<HomeworksCategory>,
42    /// Date when the homework was added.
43    pub add_date: String,
44    /// Classroom information.
45    pub classroom: Option<HomeworksClassroom>,
46}
47
48/// Reference to a homework-related resource.
49#[derive(Debug, Deserialize)]
50#[serde(rename_all = "PascalCase")]
51pub struct HomeworksCategory {
52    /// Resource ID.
53    pub id: i64,
54    /// API URL to fetch the resource.
55    pub url: String,
56}
57
58/// Classroom information.
59#[derive(Debug, Deserialize)]
60#[serde(rename_all = "PascalCase")]
61pub struct HomeworksClassroom {
62    /// Classroom ID.
63    pub id: i64,
64    /// Classroom symbol/code.
65    pub symbol: String,
66    /// Classroom name.
67    pub name: String,
68    /// Classroom capacity.
69    pub size: i64,
70}
71
72#[derive(Debug, Deserialize)]
73pub struct HomeworksResources {
74    #[serde(rename = "HomeWorks\\Categories")]
75    pub homeworks_categories: HomeworksUrl,
76    #[serde(rename = "..")]
77    pub empty: HomeworksUrl,
78}
79
80#[derive(Debug, Deserialize)]
81#[serde(rename_all = "PascalCase")]
82pub struct HomeworksUrl {
83    pub url: String,
84}