refactor: support multiple matchers in a single substitutor

This commit is contained in:
Harsh Shandilya 2022-02-20 02:45:00 +05:30
parent 0f67855571
commit 7be11d9a90
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
2 changed files with 20 additions and 8 deletions

View file

@ -13,12 +13,21 @@ pub struct Replacements<'config> {
pub struct Substitutor<'config> {
#[serde(default)]
pub name: &'config str,
#[serde(borrow)]
pub matcher: Matcher<'config>,
#[serde(borrow, alias = "matcher")]
pub matcher_type: MatcherType<'config>,
#[serde(borrow)]
pub action: Action<'config>,
}
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum MatcherType<'config> {
#[serde(borrow)]
Single(Matcher<'config>),
#[serde(borrow)]
Multiple(Vec<Matcher<'config>>),
}
#[derive(Debug, Deserialize)]
pub enum Matcher<'config> {
#[serde(rename = "starts_with")]