actr_cli/core/components/
proto_processor.rs1use anyhow::Result;
4use async_trait::async_trait;
5use std::path::Path;
6
7use super::{GenerationResult, ProtoFile, ProtoProcessor, ServiceDefinition, ValidationReport};
8
9pub struct DefaultProtoProcessor;
11
12impl DefaultProtoProcessor {
13 pub fn new() -> Self {
14 Self
15 }
16}
17
18impl Default for DefaultProtoProcessor {
19 fn default() -> Self {
20 Self::new()
21 }
22}
23
24#[async_trait]
25impl ProtoProcessor for DefaultProtoProcessor {
26 async fn discover_proto_files(&self, path: &Path) -> Result<Vec<ProtoFile>> {
27 let mut files = Vec::new();
28 if path.is_dir() {
29 for entry in std::fs::read_dir(path)? {
30 let entry = entry?;
31 let path = entry.path();
32 if path.extension().map(|e| e == "proto").unwrap_or(false) {
33 let content = std::fs::read_to_string(&path)?;
34 files.push(ProtoFile {
35 name: path.file_name().unwrap().to_string_lossy().to_string(),
36 path,
37 content,
38 services: Vec::new(),
39 });
40 }
41 }
42 }
43 Ok(files)
44 }
45
46 async fn parse_proto_services(&self, _files: &[ProtoFile]) -> Result<Vec<ServiceDefinition>> {
47 Ok(Vec::new())
49 }
50
51 async fn generate_code(&self, _input: &Path, output: &Path) -> Result<GenerationResult> {
52 Ok(GenerationResult {
54 generated_files: vec![output.to_path_buf()],
55 warnings: Vec::new(),
56 errors: Vec::new(),
57 })
58 }
59
60 async fn validate_proto_syntax(&self, _files: &[ProtoFile]) -> Result<ValidationReport> {
61 Ok(ValidationReport {
63 is_valid: true,
64 config_validation: super::ConfigValidation {
65 is_valid: true,
66 errors: Vec::new(),
67 warnings: Vec::new(),
68 },
69 dependency_validation: Vec::new(),
70 network_validation: Vec::new(),
71 fingerprint_validation: Vec::new(),
72 conflicts: Vec::new(),
73 })
74 }
75}