crev_data/proof/review/
mod.rs

1use crate::level::Level;
2pub use code::*;
3use derive_builder::Builder;
4pub use package::Draft;
5pub use package::*;
6use serde::{Deserialize, Serialize};
7use std::default::Default;
8
9pub mod code;
10pub mod package;
11
12#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialOrd, Ord, PartialEq, Eq, Default)]
13#[serde(rename_all = "lowercase")]
14pub enum Rating {
15    #[serde(alias = "dangerous")] // for backward compat with some previous versions
16    Negative,
17    #[default]
18    Neutral,
19    Positive,
20    Strong,
21}
22
23/// Information about review result
24#[derive(Clone, Debug, Serialize, Deserialize, Builder, PartialEq, Eq)]
25pub struct Review {
26    #[builder(default = "Default::default()")]
27    pub thoroughness: Level,
28    #[builder(default = "Default::default()")]
29    pub understanding: Level,
30    #[builder(default = "Default::default()")]
31    pub rating: Rating,
32}
33
34impl Default for Review {
35    fn default() -> Self {
36        Review::new_none()
37    }
38}
39
40impl Review {
41    #[must_use]
42    pub fn new_positive() -> Self {
43        Review {
44            thoroughness: Level::Low,
45            understanding: Level::Medium,
46            rating: Rating::Positive,
47        }
48    }
49
50    #[must_use]
51    pub fn new_negative() -> Self {
52        Review {
53            thoroughness: Level::Low,
54            understanding: Level::Medium,
55            rating: Rating::Negative,
56        }
57    }
58    #[must_use]
59    pub fn new_none() -> Self {
60        Review {
61            thoroughness: Level::None,
62            understanding: Level::None,
63            rating: Rating::Neutral,
64        }
65    }
66
67    #[must_use]
68    pub fn is_none(&self) -> bool {
69        *self == Self::new_none()
70    }
71}