Skip to content

Jakobzs/patternscanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

patternscanner

Build API Crate dependency status

A high performance pattern scanner for bytes.

This pattern scanner supports both single-threaded as well as multi-threaded scanning. Additionally, it is possible to include a wildcard ? in the pattern.

Installation

Add this crate as a dependency to your Cargo.toml file.

[dependencies]
patternscanner = "0.4.0"

Example

// Use the multithreaded pattern scanners
use patternscanner::mt::{pattern_scan, pattern_scan_all};

// Scan for a single match of the pattern
let result = pattern_scan(
    &[0x00, 0x01, 0x02, 0x33, 0x35, 0x33, 0x42, 0x07, 0x08, 0x09],
    "33 35",
).unwrap();
assert_eq!(result, Some(3));

// Scan for a single match of the pattern with a wildcard
let result = pattern_scan(
    &[0x00, 0x01, 0x02, 0x33, 0x35, 0x42, 0x33, 0x35, 0x69, 0x09],
    "33 ? 42",
).unwrap();
assert_eq!(result, Some(3));

// Scan for all matches of the pattern with a wildcard
let result = pattern_scan_all(
    &[0x00, 0x01, 0x02, 0x33, 0x35, 0x42, 0x33, 0x35, 0x69, 0x09],
    "33 35 ?",
).unwrap();
assert_eq!(result, [3, 6]);

License

MIT

Contributing

Contributions are welcome.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages