1use bon::Builder;
2use serde::Serialize;
3
4#[derive(Debug)]
5pub enum Severity {
6 ADVICE,
7 ERROR,
8 WARNING,
9}
10
11#[derive(Builder, Default, Debug, Clone, Serialize)]
12pub struct ProblemGroup {
13 pub name: &'static str,
14 pub display_name: &'static str,
15 pub parent: Option<Box<ProblemGroup>>,
16}
17
18impl Default for &ProblemGroup {
19 fn default() -> Self {
20 &ProblemGroup { name: "", display_name: "", parent: None }
21 }
22}
23
24#[derive(Builder, Debug, Default, Clone, Serialize)]
25pub struct ProblemSpec<'a> {
26 id: &'a ProblemGroup,
27 details: &'a str,
28 solution: Option<String>,
29 file_location: Option<String>,
30 contextual_label: &'a str,
31 }
33
34
35#[cfg(test)]
36mod test {
37 use crate::problem::ProblemSpec;
38 use crate::problem::ProblemGroup;
39
40 #[test]
41 fn test_ok() {
42 let problem_group = ProblemGroup::builder().name("test").display_name("this is a prolem").build();
50
51 println!("{:?}", serde_json::to_string(&problem_group).unwrap());
52 let problem_spec = ProblemSpec::builder().id(&problem_group).details("happen").contextual_label("fund").solution("this is soluton".to_string())
53 .file_location("herere".to_string()).build();
54
55 println!("{:?}", serde_json::to_string(&problem_spec).unwrap());
56 }
57}