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>,
pub user_config_target: Option<&'static str>,
}
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),
user_config_target: None,
}
}
#[must_use]
pub fn with_user_config_target(mut self, target_id: &'static str) -> Self {
self.user_config_target = Some(target_id);
self
}
#[must_use]
pub fn noop() -> Self {
Self {
analyze: Box::new(|_| None),
recognizes_bare: Box::new(|_| false),
user_config_target: None,
}
}
}