Struct hyperscan::chimera::DatabaseRef
source · [−]pub struct DatabaseRef(_);
Expand description
A borrowed reference to a Database
.
Implementations
sourceimpl DatabaseRef
impl DatabaseRef
sourceimpl DatabaseRef
impl DatabaseRef
sourcepub fn alloc_scratch(&self) -> Result<Scratch>
pub fn alloc_scratch(&self) -> Result<Scratch>
Allocate a scratch
space for use by Chimera.
This is required for runtime use, and one scratch space per thread, or concurrent caller, is required.
sourcepub fn realloc_scratch(&self, s: &mut Scratch) -> Result<&ScratchRef>
pub fn realloc_scratch(&self, s: &mut Scratch) -> Result<&ScratchRef>
Reallocate a scratch
space for use by Chimera.
sourceimpl DatabaseRef
impl DatabaseRef
sourcepub fn scan<'a, T, F, E>(
&self,
data: T,
scratch: &'a ScratchRef,
on_match_event: F,
on_error_event: E
) -> Result<()>where
T: AsRef<[u8]>,
F: MatchEventHandler<'a>,
E: ErrorEventHandler,
pub fn scan<'a, T, F, E>(
&self,
data: T,
scratch: &'a ScratchRef,
on_match_event: F,
on_error_event: E
) -> Result<()>where
T: AsRef<[u8]>,
F: MatchEventHandler<'a>,
E: ErrorEventHandler,
The block regular expression scanner.
Handling Matches
scan
will call a user-supplied callback when a match is found.
This closure has the following signature:
fn on_match_event(id: u32, from: u64, to: u64, flags: u32, captured: Option<&[Capture]>) -> Matching {
Matching::Continue
}
Parameters
id
: The ID number of the expression that matched.from
: The offset of the first byte that matches the expression.to
: The offset after the last byte that matches the expression.flags
: This is provided for future use and is unused at present.captured
: An array ofCapture
structures that contain the start and end offsets of entire pattern match and each captured subexpression.
Return
The callback can return Matching::Terminate
to stop matching.
Otherwise, a return value of Matching::Continue
will continue,
with the current pattern if configured to produce multiple matches per pattern,
while a return value of Matching::Skip
will cease matching this pattern but continue matching the next pattern.
Handling Runtime Errors
scan
will call a user-supplied callback when a runtime error occurs in libpcre.
This closure has the following signature:
fn on_error_event(error_type: Error, id: u32) -> Matching {
Matching::Continue
}
The id
argument will be set to the identifier for the matching expression provided at compile time.
The match callback has the capability to either halt scanning or continue scanning for the next pattern.
Return
The callback can return Matching::Skip
to cease matching this pattern but continue matching the next pattern.
Otherwise, we stop matching for all patterns with Matching::Terminate
.