#[derive(Debug, Clone, Default)]
pub struct OperatorResult {
pub matched: bool,
pub captures: Vec<String>,
pub matched_value: Option<String>,
}
impl OperatorResult {
pub fn no_match() -> Self {
Self {
matched: false,
captures: Vec::new(),
matched_value: None,
}
}
pub fn matched(value: String) -> Self {
Self {
matched: true,
captures: Vec::new(),
matched_value: Some(value),
}
}
pub fn matched_with_captures(value: String, captures: Vec<String>) -> Self {
Self {
matched: true,
captures,
matched_value: Some(value),
}
}
}
pub trait Operator: Send + Sync {
fn execute(&self, value: &str) -> OperatorResult;
fn name(&self) -> &'static str;
fn supports_capture(&self) -> bool {
false
}
}