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
use chrono::prelude::{DateTime, Utc}; mod assignment; mod level_progression; mod reset; mod review_statistic; mod review; mod study_material; mod subject; mod summary; mod user; type Time = DateTime<Utc>; #[derive(Clone, PartialEq, Debug, Deserialize)] pub struct Report<T> { pub id: Option<u32>, pub object: ObjectType, pub url: String, pub data_updated_at: Option<Time>, pub data: T, } #[derive(Clone, PartialEq, Debug, Deserialize)] #[serde(rename_all = "snake_case")] pub enum ObjectType { User, Kanji, Vocabulary, Radical, Assignment, ReviewStatistic, StudyMaterial, Summary, Review, LevelProgression, Reset, } #[derive(Clone, Debug, Deserialize)] pub struct Collection<T> { pub object: String, pub url: String, pub data_updated_at: Option<Time>, pub pages: Pages, pub total_count: u32, pub data: Vec<Report<T>>, } impl<T> IntoIterator for Collection<T> { type Item = Report<T>; type IntoIter = ::std::vec::IntoIter<Self::Item>; fn into_iter(self) -> Self::IntoIter { self.data.into_iter() } } #[derive(Clone, Debug, Deserialize)] pub struct Pages { pub per_page: u32, pub next_url: Option<String>, pub previous_url: Option<String> } pub mod prelude { pub use super::assignment::Assignment; pub use super::level_progression::LevelProgression; pub use super::reset::Reset; pub use super::review_statistic::ReviewStatistic; pub use super::review::Review; pub use super::study_material::StudyMaterial; pub use super::subject::Subject; pub use super::summary::Summary; pub use super::user::User; pub use super::{Collection, Report}; }