pub enum Pattern {
Text(String),
Regex {
regex: String,
flags: String,
},
}Expand description
String-or-regex pattern. Wire-compatible: plain JSON string ↔
Pattern::Text; tagged object {regex, flags} ↔ Pattern::Regex.
Matching is always case-insensitive: a regex missing the /i flag gets
it injected automatically; plain text compares via
eq_ignore_ascii_case.
Variants§
Text(String)
Plain literal string. An empty string never matches anything.
Regex
Compiled-on-call regex. flags defaults to “i” when absent to
satisfy maestro parity.
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn regex<P>(pattern: P) -> Pattern
pub fn regex<P>(pattern: P) -> Pattern
Construct a regex pattern. Auto-injects i flag if absent.
Sourcepub fn regex_with_flags<P, F>(pattern: P, flags: F) -> Pattern
pub fn regex_with_flags<P, F>(pattern: P, flags: F) -> Pattern
Construct a regex pattern with explicit flags.
Sourcepub fn compile(&self) -> Result<CompiledPattern, Error>
pub fn compile(&self) -> Result<CompiledPattern, Error>
Compile the wire-form pattern into a hot-path-ready CompiledPattern.
One-time cost (~5-50 μs for regex compile, ~ns for text); the
resulting CompiledPattern matches in 5-50 ns per call — the
regex compile gets fully amortized after just one re-use.
Use match_text for one-shot SDK convenience; use match_text_compiled
inside any hot resolver loop after Pattern::compile() once.
Returns Err(regex::Error) only for malformed regex patterns;
text patterns are infallible.