1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
//! This module contains all actions that [`Regex`](`super::Regex`) can be used for
use crate::action::transform::field::Field;
/// Extract some text via regex, contained in capture group "s" (?P<s>)
#[derive(Debug)]
pub struct Extract {
/// Passthrough previous text if the capture group wasn't found
pub passthrough_if_not_found: bool,
}
/// Find a re in a field
#[derive(Debug)]
pub struct Find {
/// The field to find the re in
pub in_field: Field,
}
/// Replace text that matched the re with a replacement string
#[derive(Debug)]
pub struct Replace {
/// The text to replace with. May reference capture groups in the re
pub with: String,
}
/// A stub trait that all regex actions implement
pub trait Action: sealed::Sealed {}
impl Action for Extract {}
impl Action for Find {}
impl Action for Replace {}
mod sealed {
use super::{Extract, Find, Replace};
pub trait Sealed {}
impl Sealed for Extract {}
impl Sealed for Find {}
impl Sealed for Replace {}
}