1use serde::{Deserialize, Serialize};
12use std::path::Path;
13
14#[derive(Debug, thiserror::Error)]
15pub enum OracleError {
16 #[error("capture failed: {0}")]
17 Capture(String),
18 #[error("comparison failed: {0}")]
19 Compare(String),
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct Fixture {
24 pub inputs: Vec<serde_json::Value>,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct CapturedOutputs {
29 pub outputs: Vec<serde_json::Value>,
30}
31
32#[derive(Debug, Clone)]
33pub enum ComparisonResult {
34 Match,
35 Divergence {
36 index: usize,
37 expected: String,
38 actual: String,
39 },
40}
41
42pub trait Oracle: Send + Sync {
43 fn language(&self) -> &'static str;
44
45 fn capture(&self, source: &Path, fixture: &Fixture) -> Result<CapturedOutputs, OracleError>;
46
47 fn compare(&self, expected: &CapturedOutputs, actual: &CapturedOutputs) -> ComparisonResult;
48}