use crate::price::{self, CostFact};
use crate::projection::Decline;
use crate::shuffle::Kernel;
#[derive(Debug, Clone, PartialEq)]
pub enum BuildError {
Automaton(String),
Shape(Decline),
NoQuotient,
Uncalibrated {
arch: &'static str,
kernel: Kernel,
},
NotWorthIt(CostFact),
}
impl std::fmt::Display for BuildError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Automaton(why) => write!(f, "no sieve: {why}"),
Self::Shape(d) => write!(f, "no sieve: automaton shape ({d:?})"),
Self::NoQuotient => write!(
f,
"no sieve: no register-sized closed partition discriminates"
),
Self::Uncalibrated { arch, kernel } => write!(
f,
"no sieve: nothing measured for {arch} with the {kernel:?} kernel — \
mint a calibration and pass it in a Policy"
),
Self::NotWorthIt(cost) => write!(
f,
"no sieve: {:.3}x — passes {:.2e} of positions, {:.1}% of {:.0}-byte haystacks; \
sieve {:.3} ns/B in front of a {:.3} ns/B engine",
cost.speedup(),
cost.fallthrough,
price::survival(cost.fallthrough, cost.len) * 100.0,
cost.len,
cost.sieve,
cost.rival
),
}
}
}
impl std::error::Error for BuildError {}