resume_generator/
education.rs

1crate::ix!();
2
3#[derive(Debug, Clone)]
4pub enum EducationStatus {
5    Student,
6    Graduate,
7}
8
9impl fmt::Display for EducationStatus {
10    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11        match self {
12            EducationStatus::Student => write!(f, "Student"),
13            EducationStatus::Graduate => write!(f, "Graduate"),
14        }
15    }
16}
17
18#[derive(Debug,Clone)]
19pub struct ResumeEducationInfo {
20    institution:     String,
21    location:        String,
22    degree:          String,
23    dates:           DateRange,
24    status:          Option<EducationStatus>,
25}
26
27impl LatexSectionItem for ResumeEducationInfo {
28    fn render_latex_snippet(&self) -> String {
29        let mut result = String::new();
30
31        // Institution and location
32        if !self.institution.is_empty() && !self.location.is_empty() {
33            result.push_str(&format!(
34                r#"\textbf{{{}, {}}} \\"#,
35                self.institution, self.location
36            ));
37        }
38
39        // Degree
40        if !self.degree.is_empty() {
41            result.push_str(&format!(
42                r#"\textit{{{}}} \\"#,
43                self.degree
44            ));
45        }
46
47        // Dates
48        let date_range = format_date_range(&self.dates);
49        if !date_range.is_empty() {
50            result.push_str(&format!(
51                r#"{} \\"#,
52                date_range
53            ));
54        }
55
56        // Status
57        if let Some(status) = &self.status {
58            result.push_str(&format!(
59                r#"\textit{{{}}} "#,
60                match status {
61                    EducationStatus::Student => "Student",
62                    EducationStatus::Graduate => "Graduate",
63                }
64            ));
65        }
66
67        result
68    }
69}
70
71
72impl ResumeEducationInfo {
73
74    pub fn builder() -> ResumeEducationInfoBuilder {
75        ResumeEducationInfoBuilder::default()
76    }
77
78    pub fn institution(&self) -> &str {
79        &self.institution
80    }
81
82    pub fn location(&self) -> &str {
83        &self.location
84    }
85
86    pub fn degree(&self) -> &str {
87        &self.degree
88    }
89
90    pub fn dates(&self) -> &DateRange {
91        &self.dates
92    }
93
94    pub fn status(&self) -> &Option<EducationStatus> {
95        &self.status
96    }
97}
98
99#[derive(Default)]
100pub struct ResumeEducationInfoBuilder {
101    institution:     Option<String>,
102    location:        Option<String>,
103    degree:          Option<String>,
104    dates:           Option<DateRange>,
105    status:          Option<EducationStatus>,
106}
107
108impl ResumeEducationInfoBuilder {
109    pub fn institution(mut self, institution: String) -> Self {
110        self.institution = Some(institution);
111        self
112    }
113
114    pub fn location(mut self, location: String) -> Self {
115        self.location = Some(location);
116        self
117    }
118
119    pub fn degree(mut self, degree: String) -> Self {
120        self.degree = Some(degree);
121        self
122    }
123
124    pub fn dates(mut self, dates: DateRange) -> Self {
125        self.dates = Some(dates);
126        self
127    }
128
129    pub fn status(mut self, status: EducationStatus) -> Self {
130        self.status = Some(status);
131        self
132    }
133
134    pub fn build(self) -> ResumeEducationInfo {
135        ResumeEducationInfo {
136            institution: self.institution.expect("Institution is required"),
137            location: self.location.expect("Location is required"),
138            degree: self.degree.expect("Degree is required"),
139            dates: self.dates.expect("Dates are required"),
140            status: self.status,
141        }
142    }
143}