rusty_schema_diff/
report.rs

1use serde::{Serialize, Deserialize};
2use std::collections::HashMap;
3use crate::analyzer::SchemaChange;
4
5/// Represents compatibility analysis results
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct CompatibilityReport {
8    /// List of detected changes
9    pub changes: Vec<SchemaChange>,
10    /// Overall compatibility score (0-100)
11    pub compatibility_score: u8,
12    /// Whether the schema is compatible
13    pub is_compatible: bool,
14    /// List of compatibility issues
15    pub issues: Vec<CompatibilityIssue>,
16    /// Additional metadata about the comparison
17    pub metadata: HashMap<String, String>,
18}
19
20/// Represents a specific compatibility issue
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct CompatibilityIssue {
23    /// Severity level of the issue
24    pub severity: IssueSeverity,
25    /// Description of the issue
26    pub description: String,
27    /// Location of the affected element
28    pub location: String,
29}
30
31/// Represents the severity of a compatibility issue
32#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
33pub enum IssueSeverity {
34    /// Breaking changes that must be addressed
35    Error,
36    /// Potentially problematic changes that should be reviewed
37    Warning,
38    /// Informational changes that are generally safe
39    Info,
40}
41
42/// Represents validation results for schema changes
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct ValidationResult {
45    /// Whether validation passed
46    pub is_valid: bool,
47    /// List of validation errors
48    pub errors: Vec<ValidationError>,
49    /// Additional validation context
50    pub context: HashMap<String, String>,
51}
52
53/// Represents a validation error
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct ValidationError {
56    /// Error message
57    pub message: String,
58    /// Path to the invalid element
59    pub path: String,
60    /// Error code for programmatic handling
61    pub code: String,
62}
63
64/// Represents a migration plan between schema versions
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct MigrationPlan {
67    /// List of migration steps
68    pub steps: Vec<String>,
69    /// Additional metadata about the migration
70    pub metadata: HashMap<String, String>,
71}