- Rust 100%
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE.md | ||
| README.md | ||
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.