multimatch — Multi-pattern matching engine
Why
Most scans spend most of their time matching long text against many signatures. multimatch gives a single abstraction for literal and regex signature sets with one API, optimized for batch scanning and reuse.
It can scan secrets, response patterns, shellcode markers, and sink hints across byte streams without forcing your code to juggle multiple matcher implementations.
The API composes naturally with scanclient response bytes, secreport findings, and custom scanners.
Quick Start
use ;
Features
- Convenience constructors:
from_literals,from_regexes,from_pairs. PatternSetBuilderfor rich pattern configuration (literal/regex + case-insensitive).Scannertrait withscan,is_match, andpattern_count.- Shared engine for both literals and regex with compile-time error handling (
MatchError). - Lightweight, dependency-light matching for high-throughput scanners.
TOML Configuration
multimatch does not use TOML.
API Overview
PatternSet: compiled matcher set (implementsScanner).PatternSetBuilder: add patterns and compile.PatternDef/PatternKind: individual pattern representation.MatchEngine: compiled execution engine.MatchError: parser/compile errors.MatchResult: matchedpattern_idand byte span.
Examples
1) Quick scanner for literals
use ;
let patterns = builder
.add_literal
.add_literal_ci
.build
.unwrap;
let all = patterns.scan_str;
assert!;
println!;
2) Mixed regex set for secret-format detection
use ;
let patterns = builder
.add_regex
.add_literal
.build
.unwrap;
let matches: = patterns.scan;
3) Implement Scanner for a custom matcher wrapper
use ;
Traits
multimatch defines the Scanner trait for any scan implementation. Wrap or replace the core matcher and still consume your scanner with the same downstream interfaces.
Related Crates
License
MIT, Corum Collective LLC
Docs: https://docs.rs/multimatch
Santh ecosystem: https://santh.io