use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GateResult {
pub schema_version: String,
pub spec_id: String,
pub passed: bool,
pub summary: String,
pub conditions: Vec<GateCondition>,
pub failure_reasons: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GateCondition {
pub name: String,
pub description: String,
pub passed: bool,
pub actual: Option<String>,
pub expected: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct PendingFixupsStats {
pub targets: u32,
pub est_added: u32,
pub est_removed: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PendingFixupsResult {
None,
Some(PendingFixupsStats),
Unknown {
reason: String,
},
}
impl PendingFixupsResult {
#[must_use]
pub fn is_none(&self) -> bool {
matches!(self, Self::None)
}
#[must_use]
pub fn is_some(&self) -> bool {
matches!(self, Self::Some(_))
}
#[must_use]
pub fn is_unknown(&self) -> bool {
matches!(self, Self::Unknown { .. })
}
#[must_use]
pub fn stats(&self) -> Option<&PendingFixupsStats> {
match self {
Self::Some(stats) => Some(stats),
_ => None,
}
}
#[must_use]
pub fn targets_or_zero(&self) -> u32 {
match self {
Self::Some(stats) => stats.targets,
_ => 0,
}
}
#[must_use]
pub fn into_stats(self) -> PendingFixupsStats {
match self {
Self::Some(stats) => stats,
_ => PendingFixupsStats::default(),
}
}
}
pub trait SpecDataProvider {
fn base_path(&self) -> &std::path::Path;
fn spec_id(&self) -> &str;
fn receipt_manager(&self) -> &xchecker_receipt::ReceiptManager;
fn phase_completed(&self, phase: xchecker_utils::types::PhaseId) -> bool;
fn pending_fixups_result(&self) -> PendingFixupsResult;
}