#[derive(Debug, Clone)]
pub struct UnknownSchemaError {
name: String,
}
impl UnknownSchemaError {
pub fn new(name: &str) -> Self {
Self {
name: name.to_string(),
}
}
}
impl std::fmt::Display for UnknownSchemaError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "unknown schema: {}", self.name)
}
}
impl std::error::Error for UnknownSchemaError {}
pub trait Schema {
const NAME: &'static str;
const ALIASES: &'static [&'static str] = &[];
fn mapping(c: char) -> Option<&'static str>;
fn prev_mapping(prev: Option<char>, curr: char) -> Option<&'static str>;
fn next_mapping(curr: char, next: char) -> Option<&'static str>;
fn ending_mapping(ending: [char; 2]) -> Option<&'static str>;
fn transliterate(input: &str) -> String
where
Self: Sized,
{
engine::transliterate::<Self>(input)
}
}
pub mod engine;
pub mod schemas;
pub use schemas::transliterate;