Skip to content

Hyperscan bindings for Rust with Multiple Pattern and Streaming Scan

Notifications You must be signed in to change notification settings

minio/rust-hyperscan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-hyperscan travis crate docs

Hyperscan is a high-performance regular expression matching library.

Usage

To use, add the following line to Cargo.toml under [dependencies]:

hyperscan = "0.1"

or alternatively,

hyperscan = { git = "https://github.com/flier/rust-hyperscan.git" }

Example

#[macro_use]
extern crate hyperscan;

use hyperscan::*;

fn callback(id: u32, from: u64, to: u64, flags: u32, _: &BlockDatabase) -> u32 {
    assert_eq!(id, 0);
    assert_eq!(from, 5);
    assert_eq!(to, 9);
    assert_eq!(flags, 0);

    println!("found pattern #{} @ [{}, {})", id, from, to);

    0
}

fn main() {
    let pattern = &pattern!{"test", flags => HS_FLAG_CASELESS|HS_FLAG_SOM_LEFTMOST};
    let db: BlockDatabase = pattern.build().unwrap();
    let scratch = db.alloc().unwrap();

    db.scan::<BlockDatabase>("some test data", 0, &scratch, Some(callback), Some(&db)).unwrap();
}

About

Hyperscan bindings for Rust with Multiple Pattern and Streaming Scan

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 98.9%
  • Shell 1.1%