#pattern-matching #binary-data #basic

no-std binmatch

A simple binary pattern matching crate

7 stable releases

new 1.1.0 Apr 22, 2024
1.0.5 Apr 14, 2024
1.0.4 Apr 13, 2024

#1161 in Encoding

Download history

323 downloads per month

AGPL-3.0-or-later

16KB
203 lines

Binmatch

A simple crate for binary pattern matching

Check the Docs for examples


lib.rs:

A simple binary pattern matching library

Basic Usage looks like this:

let pattern = Pattern::new("00 __ 00 ??").unwrap();
let data = vec![0x12, 0x13, 0x00, 0x14, 0x00, 0x42, 0x15];
let matches = pattern.find_matches(data); // Or Pattern::find_matches_with_index if you need the index
assert_eq!(matches, vec![0x42]);

All needed functions can be found in [Pattern]

Usage with #![no_std]

First off, disable the default feature std
cargo add binmatch --no-default-features
The normal Pattern::new is no longer accesible, because it needs std to function
Every time you wish to create a new [Pattern] you now have to use Pattern::new_unchecked

Dependencies

~120KB