#pattern-matching #binary-data #basic

no-std binmatch

A simple binary pattern matching crate

9 stable releases

1.2.1 Sep 30, 2024
1.2.0 May 8, 2024
1.1.0 Apr 22, 2024
1.0.5 Apr 14, 2024
1.0.4 Apr 13, 2024

#1874 in Encoding

Download history 2/week @ 2024-09-18 142/week @ 2024-09-25 36/week @ 2024-10-02 12/week @ 2024-10-09 5/week @ 2024-10-16

196 downloads per month

AGPL-3.0-or-later

16KB
214 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

~110KB