pub mod error;
pub mod config;
pub mod parser;
pub use error::ParseError;
pub use config::{Configuration, CountryInfo, ParserSettings};
pub fn parse_country_code(text: &str) -> Result<CountryInfo, ParseError> {
parser::parse_country_code(text)
}
#[derive(Debug, Clone)]
pub struct ParserConfig {
pub case_sensitive: bool,
pub fuzzy_match: bool,
}
impl Default for ParserConfig {
fn default() -> Self {
Self {
case_sensitive: false,
fuzzy_match: true,
}
}
}
pub struct Parser {
config: ParserConfig,
}
impl Parser {
pub fn new() -> Self {
Self {
config: ParserConfig::default(),
}
}
pub fn with_config(config: ParserConfig) -> Self {
Self { config }
}
pub fn parse(&self, text: &str) -> Result<CountryInfo, ParseError> {
parser::parse_country_code_with_config(text, &self.config)
}
}
impl Default for Parser {
fn default() -> Self {
Self::new()
}
}