1pub mod error;
7pub mod config;
8pub mod parser;
9
10pub use error::ParseError;
12pub use config::{Configuration, CountryInfo, ParserSettings};
13
14
15
16pub fn parse_country_code(text: &str) -> Result<CountryInfo, ParseError> {
27 parser::parse_country_code(text)
28}
29
30#[derive(Debug, Clone)]
32pub struct ParserConfig {
33 pub case_sensitive: bool,
35 pub fuzzy_match: bool,
37}
38
39impl Default for ParserConfig {
40 fn default() -> Self {
41 Self {
42 case_sensitive: false,
43 fuzzy_match: true,
44 }
45 }
46}
47
48pub struct Parser {
50 config: ParserConfig,
51}
52
53impl Parser {
54 pub fn new() -> Self {
56 Self {
57 config: ParserConfig::default(),
58 }
59 }
60
61 pub fn with_config(config: ParserConfig) -> Self {
63 Self { config }
64 }
65
66 pub fn parse(&self, text: &str) -> Result<CountryInfo, ParseError> {
68 parser::parse_country_code_with_config(text, &self.config)
69 }
70}
71
72impl Default for Parser {
73 fn default() -> Self {
74 Self::new()
75 }
76}