A set of Serde-compatible structs for providing configurable text matching / substitution.
Find a file
2025-07-27 23:29:31 -04:00
src reimplement string comparisons to use regex for better capturing 2025-07-27 23:29:31 -04:00
.gitignore Initial commit 2025-07-26 23:45:58 -04:00
Cargo.lock Initial commit 2025-07-26 23:45:58 -04:00
Cargo.toml Start documenting changes, change "ignore case" to "case sensitive" 2025-07-27 00:17:54 -04:00
LICENSE.md Initial commit 2025-07-26 23:45:58 -04:00
README.md Start documenting changes, change "ignore case" to "case sensitive" 2025-07-27 00:17:54 -04:00

cfg-matchers

A set of Serde-compatible structs for providing configurable text matching / substitution in your applications.

Usage

To add configurable matching to your application, add the following somewhere in your configuration structs:

use serde::{Deserialize, Serialize};
// We use the base string matcher type for this example; others for specific use-cases exist too
use cfg_matchers::matchers::base::Matcher;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Config {
    #[serde(rename = "match", default)]
    pub matching: Vec<Matcher>,
}

Then, the configuration would look something like this (in TOML):

# This will match the string "beans" exactly.
[[match]]
on = "exact"
text = "beans"
case_sensitive = false # Matchers are case-sensitive by default, this disables case sensitivity.

# This regex matcher will match a US 10-digit phone number.
# This uses the Rust regex engine implementation detailed in https://docs.rs/regex
[[match]]
on = "regex"
expr = "\\(?(\\d{3})\\)\\D*(\\d{3})\\D*(\\d{4})"

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.