actr_version/types.rs
1//! Core types for actr-version compatibility analysis
2//!
3//! These are business logic types specific to compatibility analysis,
4//! separate from the protocol layer types in actr-protocol.
5
6use serde::{Deserialize, Serialize};
7
8/// Compatibility level between two protocol versions
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
10#[repr(i32)]
11pub enum CompatibilityLevel {
12 /// No changes detected (semantic fingerprints match)
13 FullyCompatible = 0,
14 /// Changes present but backward compatible
15 BackwardCompatible = 1,
16 /// Breaking changes detected
17 BreakingChanges = 2,
18}
19
20/// Simplified proto file representation for convenience
21/// (adapts from actr_protocol::service_spec::Protobuf)
22#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
23pub struct ProtoFile {
24 /// File name (e.g., "user.proto")
25 pub name: String,
26 /// Proto file content
27 pub content: String,
28 /// Optional file path (for local development)
29 pub path: Option<String>,
30}
31
32impl ProtoFile {
33 /// Extract filename from URI or path
34 /// e.g., "actr://service/proto/user.proto" → "user.proto"
35 /// Used for compatibility with old URI-based references
36 pub fn name_from_uri(uri: &str) -> String {
37 uri.rsplit('/').next().unwrap_or(uri).to_string()
38 }
39
40 /// Create from protocol Protobuf message (package-level)
41 /// The Protobuf structure represents a merged package, so we use package name directly
42 pub fn from_protobuf(proto: &actr_protocol::service_spec::Protobuf) -> Self {
43 Self {
44 name: proto.package.clone(), // Package name (e.g., "user.v1")
45 content: proto.content.clone(),
46 path: None,
47 }
48 }
49}