use std::path::Path;
use super::types::InstallMethod;
pub struct InstallProbe {
pub analyze: Box<dyn Fn(&Path) -> Option<InstallMethod> + Send + Sync>,
pub recognizes_bare: Box<dyn Fn(&Path) -> bool + Send + Sync>,
}
impl InstallProbe {
pub fn new<A, B>(analyze: A, recognizes_bare: B) -> Self
where
A: Fn(&Path) -> Option<InstallMethod> + Send + Sync + 'static,
B: Fn(&Path) -> bool + Send + Sync + 'static,
{
Self {
analyze: Box::new(analyze),
recognizes_bare: Box::new(recognizes_bare),
}
}
pub fn noop() -> Self {
Self {
analyze: Box::new(|_| None),
recognizes_bare: Box::new(|_| false),
}
}
}