pub mod parser;
use std::sync::Arc;
use crate::registry::{AddressRegistry, SearchResult};
pub struct SearchEngine {
registry: Arc<AddressRegistry>,
}
impl SearchEngine {
pub fn new(registry: Arc<AddressRegistry>) -> Self {
Self { registry }
}
pub fn suggest(&self, input: &str) -> Vec<SearchResult> {
self.registry.search(input, 200)
}
pub fn classify(&self, input: &str) -> Result<parser::SearchQuery, String> {
parser::classify(input, &self.registry)
}
pub fn registry(&self) -> &AddressRegistry {
&self.registry
}
}