#[cfg(feature = "boha")]
mod boha;
#[cfg(not(feature = "boha"))]
use anyhow::anyhow;
use anyhow::Result;
#[derive(Debug, Clone)]
pub struct ProviderResult {
pub id: String,
pub pubkey: Option<String>,
pub start: Option<String>,
#[allow(dead_code)]
pub end: Option<String>,
pub range_bits: Option<u32>,
}
pub fn resolve(input: &str) -> Result<Option<ProviderResult>> {
let Some((provider, query)) = input.split_once(':') else {
return Ok(None);
};
if provider.len() == 1 {
return Ok(None);
}
match provider {
#[cfg(feature = "boha")]
"boha" => boha::resolve(query).map(Some),
#[cfg(not(feature = "boha"))]
"boha" => Err(anyhow!(
"boha provider requires the 'boha' feature. Rebuild with: cargo build --features boha"
)),
_ => {
let _ = query;
Ok(None)
}
}
}
#[cfg(feature = "boha")]
pub fn list_available() -> Vec<(String, String, String, Option<u32>, bool)> {
boha::list_available()
}
#[cfg(not(feature = "boha"))]
pub fn list_available() -> Vec<(String, String, String, Option<u32>, bool)> {
vec![]
}
pub fn supported_providers() -> Vec<&'static str> {
#[cfg(feature = "boha")]
{
vec!["boha"]
}
#[cfg(not(feature = "boha"))]
{
vec![]
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_resolve_not_provider() {
let result = resolve("just-a-string").unwrap();
assert!(result.is_none());
}
#[test]
fn test_resolve_windows_path() {
let result = resolve("C:\\Users\\test").unwrap();
assert!(result.is_none());
}
}