1pub mod compiler;
8pub mod engine;
9pub mod rule;
10pub mod tables;
11pub mod trie;
12
13#[cfg(feature = "wasm")]
14pub mod wasm;
15
16pub use compiler::CompiledLayout;
17pub use engine::LekhaniParser;
18pub use rule::{ConditionScope, MatchType, Pattern, PatternRule, RuleCondition};
19
20use std::sync::{Arc, OnceLock};
21
22static DEFAULT_AVRO_LAYOUT: OnceLock<Arc<CompiledLayout>> = OnceLock::new();
25
26const EMBEDDED_AVRO_JSON: &str = include_str!("../data/avrophonetic.json");
28
29pub fn get_default_avro_layout() -> Arc<CompiledLayout> {
31 DEFAULT_AVRO_LAYOUT
32 .get_or_init(|| {
33 let json: serde_json::Value = serde_json::from_str(EMBEDDED_AVRO_JSON)
34 .expect("Corrupt embedded avrophonetic.json layout");
35 let layout = CompiledLayout::from_json(&json)
36 .expect("Failed to compile embedded avrophonetic.json");
37 Arc::new(layout)
38 })
39 .clone()
40}
41
42pub fn default_avro_parser() -> LekhaniParser {
44 LekhaniParser::new(get_default_avro_layout())
45}