use super::{Declined, Plan, PlanTree};
pub struct Fastest<I, O> {
table: &'static str,
launch: Box<dyn Fn(&I) -> O + Send + Sync>,
}
impl<I, O> Fastest<I, O> {
pub fn new(table: &'static str, launch: impl Fn(&I) -> O + Send + Sync + 'static) -> Self {
Self {
table,
launch: Box::new(launch),
}
}
}
impl<I, O> Plan<I> for Fastest<I, O> {
type Output = O;
fn launch(&self, inputs: &I) -> Result<O, Declined> {
Ok((self.launch)(inputs))
}
fn tree(&self) -> PlanTree {
PlanTree::Fastest(self.table.to_string())
}
}