rusty_schema_diff/
report.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
use crate::analyzer::SchemaChange;

/// Represents compatibility analysis results
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CompatibilityReport {
    /// List of detected changes
    pub changes: Vec<SchemaChange>,
    /// Overall compatibility score (0-100)
    pub compatibility_score: u8,
    /// Whether the schema is compatible
    pub is_compatible: bool,
    /// List of compatibility issues
    pub issues: Vec<CompatibilityIssue>,
    /// Additional metadata about the comparison
    pub metadata: HashMap<String, String>,
}

/// Represents a specific compatibility issue
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CompatibilityIssue {
    /// Severity level of the issue
    pub severity: IssueSeverity,
    /// Description of the issue
    pub description: String,
    /// Location of the affected element
    pub location: String,
}

/// Represents the severity of a compatibility issue
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum IssueSeverity {
    /// Breaking changes that must be addressed
    Error,
    /// Potentially problematic changes that should be reviewed
    Warning,
    /// Informational changes that are generally safe
    Info,
}

/// Represents validation results for schema changes
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ValidationResult {
    /// Whether validation passed
    pub is_valid: bool,
    /// List of validation errors
    pub errors: Vec<ValidationError>,
    /// Additional validation context
    pub context: HashMap<String, String>,
}

/// Represents a validation error
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ValidationError {
    /// Error message
    pub message: String,
    /// Path to the invalid element
    pub path: String,
    /// Error code for programmatic handling
    pub code: String,
}

/// Represents a migration plan between schema versions
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MigrationPlan {
    /// List of migration steps
    pub steps: Vec<String>,
    /// Additional metadata about the migration
    pub metadata: HashMap<String, String>,
}