use serde::{Deserialize, Serialize};
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct Clip {
pub x: u32,
pub y: u32,
pub height: u32,
pub width: u32,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct RunnerExtras {
pub help_url: &'static str,
pub description: &'static str,
pub impact: &'static str,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct Issue {
pub context: String,
pub selectors: Vec<String>,
pub code: String,
pub issue_type: &'static str,
pub type_code: u8,
pub message: String,
pub runner: &'static str,
pub runner_extras: RunnerExtras,
pub recurrence: u32,
pub clip: Option<Clip>,
}
impl Issue {
pub fn new(
message: String,
context: &str,
code: &str,
issue_type: &'static str,
selectors: Vec<String>,
) -> Issue {
Issue {
message,
context: context.into(),
runner: "accessibility-rs",
code: code.into(),
issue_type,
type_code: match issue_type {
"error" => 0,
"warning" => 1,
_ => 2,
},
selectors,
..Default::default()
}
}
}