use bon::Builder;
use serde::Serialize;
#[derive(Debug)]
pub enum Severity {
ADVICE,
ERROR,
WARNING,
}
#[derive(Builder, Default, Debug, Clone, Serialize)]
pub struct ProblemGroup {
pub name: &'static str,
pub display_name: &'static str,
pub parent: Option<Box<ProblemGroup>>,
}
impl Default for &ProblemGroup {
fn default() -> Self {
&ProblemGroup { name: "", display_name: "", parent: None }
}
}
#[derive(Builder, Debug, Default, Clone, Serialize)]
pub struct ProblemSpec<'a> {
id: &'a ProblemGroup,
details: &'a str,
solution: Option<String>,
file_location: Option<String>,
contextual_label: &'a str,
}
#[cfg(test)]
mod test {
use crate::problem::ProblemSpec;
use crate::problem::ProblemGroup;
#[test]
fn test_ok() {
let problem_group = ProblemGroup::builder().name("test").display_name("this is a prolem").build();
println!("{:?}", serde_json::to_string(&problem_group).unwrap());
let problem_spec = ProblemSpec::builder().id(&problem_group).details("happen").contextual_label("fund").solution("this is soluton".to_string())
.file_location("herere".to_string()).build();
println!("{:?}", serde_json::to_string(&problem_spec).unwrap());
}
}