-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: nest struct definition using nest_struct crate
- Loading branch information
1 parent
c75551d
commit 0086083
Showing
4 changed files
with
89 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,38 @@ | ||
use nest_struct::nest_struct; | ||
#[cfg(feature = "serde_derive")] | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, PartialEq)] | ||
#[cfg_attr(feature = "serde_derive", derive(Serialize))] | ||
pub struct NodeName { | ||
pub ar: &'static str, | ||
pub en: &'static str, | ||
pub fr: &'static str, | ||
} | ||
|
||
#[derive(Debug, PartialEq)] | ||
#[cfg_attr( | ||
feature = "serde_derive", | ||
derive(Serialize), | ||
serde(tag = "type"), | ||
serde(rename_all = "UPPERCASE") | ||
)] | ||
pub enum NodeType { | ||
University, | ||
Academy, | ||
PrivateSchool, | ||
Institute, | ||
Faculty, | ||
Department, | ||
Specialty { terms: NodeTerms }, | ||
Sector { terms: NodeTerms }, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone)] | ||
#[cfg_attr( | ||
feature = "serde_derive", | ||
derive(Serialize), | ||
serde(rename_all = "camelCase") | ||
)] | ||
pub struct NodeTerms { | ||
pub per_year: usize, | ||
pub slots: &'static [i32], | ||
} | ||
|
||
#[nest_struct] | ||
#[derive(Debug, PartialEq)] | ||
#[cfg_attr(feature = "serde_derive", derive(Serialize))] | ||
pub struct Node { | ||
pub name: NodeName, | ||
pub name: nest! { | ||
pub ar: &'static str, | ||
pub en: &'static str, | ||
pub fr: &'static str, | ||
}, | ||
#[cfg_attr(feature = "serde_derive", serde(flatten))] | ||
pub r#type: NodeType, | ||
pub r#type: nest! { | ||
#[derive(Debug, PartialEq)] | ||
#[cfg_attr(feature = "serde_derive", derive(Serialize), serde(tag = "type"), serde(rename_all = "UPPERCASE"))] | ||
pub enum NodeType { | ||
University, | ||
Academy, | ||
PrivateSchool, | ||
Institute, | ||
Faculty, | ||
Department, | ||
Specialty { | ||
terms: nest! { | ||
#[derive(Debug, PartialEq, Clone)] | ||
#[cfg_attr(feature = "serde_derive", derive(Serialize), serde(rename_all = "camelCase"))] | ||
pub struct NodeTerms { | ||
pub per_year: usize, | ||
pub slots: &'static [i32], | ||
} | ||
} | ||
}, | ||
Sector { terms: NodeTerms }, | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,39 @@ | ||
use nest_struct::nest_struct; | ||
use serde::Deserialize; | ||
#[cfg(feature = "serde_derive")] | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, PartialEq, Deserialize)] | ||
#[cfg_attr(feature = "serde_derive", derive(Serialize))] | ||
pub struct NodeName { | ||
pub ar: String, | ||
pub en: String, | ||
pub fr: String, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Deserialize)] | ||
#[cfg_attr( | ||
feature = "serde_derive", | ||
derive(Serialize), | ||
serde(tag = "type"), | ||
serde(rename_all = "UPPERCASE") | ||
)] | ||
pub enum NodeType { | ||
University, | ||
Academy, | ||
PrivateSchool, | ||
Institute, | ||
Faculty, | ||
Department, | ||
Specialty { terms: NodeTerms }, | ||
Sector { terms: NodeTerms }, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone, Deserialize)] | ||
#[cfg_attr( | ||
feature = "serde_derive", | ||
derive(Serialize), | ||
serde(rename_all = "camelCase") | ||
)] | ||
pub struct NodeTerms { | ||
pub per_year: usize, | ||
pub slots: Vec<i32>, | ||
} | ||
|
||
#[nest_struct] | ||
#[derive(Debug, PartialEq, Deserialize)] | ||
#[cfg_attr(feature = "serde_derive", derive(Serialize))] | ||
pub struct Node { | ||
pub name: NodeName, | ||
pub name: nest! { | ||
pub ar: String, | ||
pub en: String, | ||
pub fr: String, | ||
}, | ||
#[cfg_attr(feature = "serde_derive", serde(flatten))] | ||
pub r#type: NodeType, | ||
pub r#type: nest! { | ||
#[derive(Debug, PartialEq, Deserialize)] | ||
#[cfg_attr(feature = "serde_derive", derive(Serialize), serde(tag = "type"), serde(rename_all = "UPPERCASE"))] | ||
pub enum NodeType { | ||
University, | ||
Academy, | ||
PrivateSchool, | ||
Institute, | ||
Faculty, | ||
Department, | ||
Specialty { | ||
terms: nest! { | ||
#[derive(Debug, PartialEq, Clone, Deserialize)] | ||
#[cfg_attr(feature = "serde_derive", derive(Serialize), serde(rename_all = "camelCase"))] | ||
pub struct NodeTerms { | ||
pub per_year: usize, | ||
pub slots: Vec<i32>, | ||
} | ||
} | ||
}, | ||
Sector { terms: NodeTerms }, | ||
} | ||
}, | ||
} |