| Crates.io | patterns |
| lib.rs | patterns |
| version | 0.3.1 |
| created_at | 2023-04-07 15:46:51.123116+00 |
| updated_at | 2025-07-30 18:40:07.287749+00 |
| description | no_std, no alloc pattern scan library using simd |
| homepage | |
| repository | https://github.com/greaka/patterns |
| max_upload_size | |
| id | 832986 |
| size | 81,789 |
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, no alloc. Additionally, all panics are documented and are limited to pattern creation.
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
}
More advanced use cases may also specify a target alignment required to match, or the LANE size with which to search:
use patterns::Pattern;
static PATTERN: Pattern<4, 64> = Pattern::new("00 01 02 . ff");
data.as_ptr() - 64 > [usize::MIN]data.as_ptr() + data.len() + 64 < [usize::MAX]In practice, it's impossible to be outside of these bounds when using an OS.