pub_just/
warning.rs

1use super::*;
2
3#[derive(Clone, Debug, PartialEq)]
4pub enum Warning {}
5
6impl Warning {
7  #[allow(clippy::unused_self)]
8  fn context(&self) -> Option<&Token> {
9    None
10  }
11}
12
13impl ColorDisplay for Warning {
14  fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result {
15    let warning = color.warning();
16    let message = color.message();
17
18    write!(f, "{} {}", warning.paint("warning:"), message.prefix())?;
19
20    write!(f, "{}", message.suffix())?;
21
22    if let Some(token) = self.context() {
23      writeln!(f)?;
24      write!(f, "{}", token.color_display(color))?;
25    }
26
27    Ok(())
28  }
29}
30
31impl Serialize for Warning {
32  fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
33  where
34    S: Serializer,
35  {
36    let mut map = serializer.serialize_map(None)?;
37
38    map.serialize_entry("message", &self.color_display(Color::never()).to_string())?;
39
40    map.end()
41  }
42}