1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Chimera is a software regular expression matching engine that is a hybrid of Hyperscan and PCRE.
//!
//! The design goals of Chimera are to fully support PCRE syntax as well as to
//! take advantage of the high performance nature of Hyperscan.
//!
//! # Examples
//!
//! ```rust
//! # use hyperscan::chimera::prelude::*;
//! let db: Database = "/test/i".parse().unwrap();
//! let scratch = db.alloc_scratch().unwrap();
//! let mut matches = vec![];
//! let mut errors = vec![];
//!
//! db.scan("some test data", &scratch, |id, from, to, _flags, captured| {
//!     matches.push((from, to));
//!
//!     Matching::Continue
//! }, |error_type, id| {
//!     errors.push((error_type, id));
//!
//!     Matching::Skip
//! }).unwrap();
//!
//! assert_eq!(matches, vec![(5, 9)]);
//! assert_eq!(errors, vec![]);
//! ```
mod common;
mod compile;
mod error;
mod pattern;
mod runtime;

#[doc(hidden)]
pub use crate::ffi::chimera as ffi;

pub use self::common::{version, Database, DatabaseRef};
pub use self::compile::{compile, Builder, CompileError, Mode};
pub use self::error::Error;
pub use self::pattern::{Flags, Pattern, Patterns};
pub use self::runtime::{
    Capture, Error as MatchError, ErrorEventHandler, MatchEventHandler, Matching, Scratch, ScratchRef,
};

pub mod prelude {
    //! The `chimera` Prelude
    pub use crate::chimera::{
        compile, Builder, Capture, Database, DatabaseRef, Error, Matching, Pattern, Patterns, Scratch, ScratchRef,
    };
}