xbp-analysis 10.57.0

Language-agnostic static analysis (error-handling / Aspirator-style) for XBP
Documentation
//! Outbound ports (infrastructure interfaces).

use crate::domain::report::AnalysisReport;
use crate::domain::request::AnalysisConfig;
use crate::domain::types::{Finding, LanguageId, SourceFile};
use std::path::{Path, PathBuf};

/// Discover source files in a workspace.
pub trait WorkspaceDiscovery: Send + Sync {
    fn discover(
        &self,
        root: &Path,
        languages: &[LanguageId],
        exclusions: &[String],
    ) -> Result<Vec<PathBuf>, String>;
}

/// Load source text.
pub trait SourceLoader: Send + Sync {
    fn load(&self, path: &Path, language: LanguageId) -> Result<SourceFile, String>;
}

/// Load config from disk / env.
pub trait ConfigLoader: Send + Sync {
    fn load_analysis_config(&self, root: &Path) -> Result<AnalysisConfig, String>;
}

/// Render diagnostics for humans or machines.
pub trait DiagnosticRenderer: Send + Sync {
    fn render(&self, report: &AnalysisReport) -> Result<String, String>;
}

/// Persist analysis cache entries.
pub trait AnalysisCache: Send + Sync {
    fn get(&self, key: &str) -> Option<Vec<Finding>>;
    fn put(&self, key: &str, findings: &[Finding]);
}

/// Write fixed source back to storage.
pub trait SourceWriter: Send + Sync {
    fn write(&self, path: &Path, content: &str) -> Result<(), String>;
}

/// Compute content hash for caching.
pub fn content_hash(content: &str) -> String {
    blake3::hash(content.as_bytes()).to_hex().to_string()
}