mod apply;
mod class;
mod codepoint;
mod emoji;
mod error;
mod family;
mod map;
mod walk;
mod words;
pub(crate) use apply::fix_under;
pub use apply::{Fixed, Report, fix};
pub use error::Error;
pub(crate) use map::BUILTIN;
pub use map::Map;
use crate::rules::Origin;
use crate::scan::Hit;
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct Family {
pub name: String,
pub parent: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct Member {
pub family: String,
pub text: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct Class {
pub name: String,
pub members: Vec<Member>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct MapEntry {
pub from: String,
pub to: String,
pub word: bool,
pub origin: Origin,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct Rewrite {
pub hit: Hit,
pub to: String,
}
#[derive(Clone, Copy)]
pub(crate) struct Law<'a> {
pub allowed: &'a dyn Fn(char) -> bool,
pub hazards: &'a HazardsIn<'a>,
pub kept: &'a KeptIn<'a>,
pub restores: &'a RestoresIn<'a>,
}
pub(crate) type HazardsIn<'a> = dyn Fn(&str) -> Vec<Hazard> + 'a;
pub(crate) type KeptIn<'a> = dyn Fn(&str) -> Vec<usize> + 'a;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct Hazard {
pub byte: usize,
pub delete: bool,
}
pub(crate) type RestoresIn<'a> = dyn Fn(&str) -> Vec<Restore> + 'a;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct Restore {
pub byte: usize,
pub len: usize,
pub to: char,
}
#[derive(Debug, Default)]
pub(crate) struct Marks {
pub hazards: Vec<Hazard>,
pub kept: Vec<usize>,
pub restores: Vec<Restore>,
}
impl Marks {
pub(crate) fn of(text: &str, law: Law<'_>) -> Self {
Self {
hazards: (law.hazards)(text),
kept: (law.kept)(text),
restores: (law.restores)(text),
}
}
}