//! Source provenance retained with measured paint, never reconstructed by text. use crate::execution::TokenOrigin; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] pub enum Derivation { FontProgram, Hyphenation, Fraction, Delimiter, Radical, Accent, MathVariant, MathRule, } #[derive(Clone, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] pub struct PaintSource { pub tokens: Vec, pub derivations: Vec, } impl PaintSource { pub fn token(origin: TokenOrigin) -> Self { Self { tokens: vec![origin], derivations: Vec::new(), } } pub fn merge(&mut self, other: &Self) { for token in &other.tokens { if !self.tokens.contains(token) { self.tokens.push(*token); } } for derivation in &other.derivations { if !self.derivations.contains(derivation) { self.derivations.push(*derivation); } } } pub fn derived(mut self, derivation: Derivation) -> Self { if !self.derivations.contains(&derivation) { self.derivations.push(derivation); } self } }