Files
faunosteo/crates/worker/src/verifier.rs
T

30 lines
841 B
Rust

//! The verify step as the job sees it: a framed input in, a classified child run out. The
//! real implementation spawns this very binary as `verify` (V1-2.3); tests inject outcomes.
use crate::spawn::{ChildRun, Spawner};
pub trait Verifier {
fn verify(&self, frame: &[u8]) -> ChildRun;
}
/// Spawns `faunosteo-worker verify` from the running executable.
#[derive(Debug, Clone)]
pub struct ChildVerifier {
spawner: Spawner,
}
impl ChildVerifier {
/// Fails only when the executable path cannot be resolved (then nothing can be verified).
pub fn from_current_exe() -> std::io::Result<Self> {
Ok(Self {
spawner: Spawner::for_verify(std::env::current_exe()?),
})
}
}
impl Verifier for ChildVerifier {
fn verify(&self, frame: &[u8]) -> ChildRun {
self.spawner.run(frame)
}
}