Crate hyperscan

Source
Expand description

Hyperscan is a high-performance regular expression matching library.

§Usage

This crate is on crates.io and can be used by adding hyperscan to your dependencies in your project’s Cargo.toml.

[dependencies]
hyperscan = "0.3"

§Examples

#[macro_use]
extern crate hyperscan;

use hyperscan::prelude::*;

fn main() {
    let pattern = pattern! {"test"; CASELESS | SOM_LEFTMOST};
    let db: BlockDatabase = pattern.build().unwrap();
    let scratch = db.alloc_scratch().unwrap();

    db.scan("some test data", &scratch, |id, from, to, _flags| {
        assert_eq!(id, 0);
        assert_eq!(from, 5);
        assert_eq!(to, 9);

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

        Matching::Continue
    }).unwrap();
}

Modules§

chimera
Chimera is a software regular expression matching engine that is a hybrid of Hyperscan and PCRE.
prelude
The hyperscan Prelude
regex
Regex compatible interface

Macros§

literal
Define Literal with flags
literals
Define multi Literal with flags and ID
pattern
Define Pattern with flags
patterns
Define multi Pattern with flags and ID

Structs§

CompileError
Providing details of the compile error condition.
CpuFeatures
CPU feature support flags
Database
A compiled pattern database that can then be used to scan data.
DatabaseRef
A borrowed reference to a Database.
ExprExt
A structure containing additional parameters related to an expression.
ExprInfo
A type containing information related to an expression
Literal
The pattern with pure literal expression.
LiteralFlags
Literal flags
Literals
Vec of Literal
Pattern
The pattern with basic regular expression.
PatternFlags
Pattern flags
Patterns
Vec of Pattern
Platform
A type containing information on the target platform which may optionally be provided to the compile calls
PlatformRef
A borrowed reference to a Platform.
Scratch
A large enough region of scratch space to support a given database.
ScratchRef
A borrowed reference to a Scratch.
Stream
A pattern matching state can be maintained across multiple blocks of target data
StreamRef
A borrowed reference to a Stream.

Enums§

BlockMode
Block scan (non-streaming) database.
Error
Hyperscan Error
HsError
Hyperscan Error Codes
Matching
Indicating whether or not matching should continue on the target data.
SomHorizon
Defines the precision to track start of match offsets in stream state.
StreamingMode
Streaming database.
Tune
Tuning Parameter
VectoredMode
Vectored scanning database.

Traits§

Builder
The regular expression pattern database builder.
DatabaseBuilder
The regular expression pattern database builder.
MatchEventHandler
Definition of the match event callback function type.
Mode
Compile mode
SerializedDatabase
A serialized database

Functions§

compile
Compile an expression into a Hyperscan database.
version
The current Hyperscan version information.
version_str
Utility function for identifying this release version.

Type Aliases§

BlockDatabase
Block scan (non-streaming) database.
Result
The type returned by hyperscan methods.
StreamingDatabase
Streaming database.
VectoredDatabase
Vectored scanning database.