multimatch 0.2.0

Multi-pattern matching engine — Aho-Corasick + regex
Documentation
# multimatch

Search text for many patterns at once. Literals go through Aho-Corasick (one pass, any number of patterns). Regexes run in parallel. Optional Hyperscan SIMD backend for 3-5x throughput.

```rust
use multimatch::{PatternSet, Scanner};

let patterns = PatternSet::builder()
    .add_literal("password", 0)
    .add_literal("secret", 1)
    .add_regex(r"[A-Za-z0-9]{32,}", 2)
    .build()
    .unwrap();

let matches = patterns.scan(b"my password is abc123secretXYZ");
for m in &matches {
    println!("pattern {} at {}..{}", m.pattern_id, m.start, m.end);
}
```

## Why not just use aho-corasick + regex directly?

You can. multimatch wraps them into a single interface so you don't juggle two APIs. It also:

- Separates case-sensitive and case-insensitive literals into distinct automata (faster than one mixed automaton)
- Pre-allocates result buffers based on pattern count
- Provides the `Scanner` trait so you can swap backends without changing calling code
- Adds convenience constructors: `from_literals(&["a", "b", "c"])` builds a pattern set in one line

If Hyperscan is available and you enable the `simd` feature, the same code runs 3-5x faster with zero API changes.

## The Scanner trait

Any pattern matching backend can implement `Scanner`:

```rust
use multimatch::{Scanner, MatchResult};

struct MyCustomMatcher;

impl Scanner for MyCustomMatcher {
    fn scan(&self, input: &[u8]) -> Vec<MatchResult> { vec![] }
    fn is_match(&self, input: &[u8]) -> bool { false }
    fn pattern_count(&self) -> usize { 0 }
}
```

## Convenience

```rust
// Build from a list of strings
let ps = multimatch::from_literals(&["eval(", "exec(", "system("]).unwrap();

// Build from regex patterns
let ps = multimatch::from_regexes(&[r"\d{3}-\d{4}", r"[A-Z]{5}"]).unwrap();
```

## SIMD acceleration

Enable Hyperscan (requires libhs installed):

```toml
[dependencies]
multimatch = { version = "0.1", features = ["simd"] }
```

Same API, faster execution. Falls back to Aho-Corasick + regex on systems without Hyperscan.

## Contributing

Pull requests are welcome. There is no such thing as a perfect crate. If you find a bug, a better API, or just a rough edge, open a PR. We review quickly.

## License

MIT. Copyright 2026 CORUM COLLECTIVE LLC.

[![crates.io](https://img.shields.io/crates/v/multimatch.svg)](https://crates.io/crates/multimatch)
[![docs.rs](https://docs.rs/multimatch/badge.svg)](https://docs.rs/multimatch)