use serde::Serialize;
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub struct RouteCatalogSnapshot {
pub rule_sets: Vec<RuleSetView>,
pub fallback_respond_dir: Option<String>,
}
impl RouteCatalogSnapshot {
pub fn empty() -> Self {
Self {
rule_sets: Vec::new(),
fallback_respond_dir: None,
}
}
}
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub struct RuleSetView {
pub index: usize,
pub source_path: String,
pub url_path_prefix: Option<String>,
pub respond_dir_prefix: Option<String>,
pub rules: Vec<RuleView>,
}
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub struct RuleView {
pub index: usize,
pub when_summary: String,
pub respond: RespondView,
}
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub enum RespondView {
File { path: String, csv_records_key: Option<String> },
Text { text: String, status: Option<u16> },
Status { code: u16 },
}
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub struct RouteMatchView {
pub matched: Option<MatchedRule>,
pub considered: Vec<MatchConsidered>,
}
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub struct MatchedRule {
pub rule_set_index: usize,
pub rule_index: usize,
}
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub struct MatchConsidered {
pub rule_set_index: usize,
pub rule_index: usize,
pub reason: String,
}
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub struct RouteValidation {
pub ok: bool,
pub issues: Vec<RouteValidationIssue>,
}
impl RouteValidation {
pub fn ok() -> Self {
Self {
ok: true,
issues: Vec::new(),
}
}
}
#[derive(Clone, Debug, Serialize)]
#[non_exhaustive]
pub struct RouteValidationIssue {
pub rule_set_index: usize,
pub rule_index: Option<usize>,
pub severity: ValidationSeverity,
pub message: String,
}
#[derive(Clone, Copy, Debug, Serialize)]
pub enum ValidationSeverity {
Error,
Warning,
}