Expand description
§Pattern matching library
Allows you to search for a pattern within data via an iterator interface. This library uses the core::simd abstraction and is fully no_std compatible.
§Usage
use patterns::Pattern;
let data = [0_u8; 1_000_00];
// Allows . and ? as wildcard.
// Any number of wildcard characters between spaces is considered a wildcard byte.
let pattern: Pattern = "01 02 00 ? 59 ff".parse().unwrap();
let mut iterator = pattern.matches(&data);
for _found in iterator {
// use _found
}
§Limitations
- The maximum amount of bytes supported inside a pattern are 64 bytes
- Target alignment of the pattern to search for must be less or equal to 64
- The pointer of data to search through must follow these invariants:
data.as_ptr() - 64 >
usize::MIN
data.as_ptr() + data.len() + 64 <
usize::MAX
Structs§
- Pattern
- A prepared pattern. Allows to search for a given byte sequence in data. Supports masking and alignment requirements.
- Scanner
- An
Iterator
for searching a givenPattern
in data
Constants§
- OPTIMAL_
BYTES - Provides a constant optimizing
BYTES
(seePattern
) to target cpu simd width. This is a best-effort, defaulting to maximum supported bytes.
Type Aliases§
- Bytes
Mask - The type that holds a bit for each byte in [
BYTES
]