pub struct HsScanner { /* private fields */ }Expand description
Compiled Hyperscan databases for all detector patterns, sharded across cores at compile time.
Thread-safe: every database is immutable after compilation and the
scratch pools are Mutex-guarded. The public scan/lookup surface is
unchanged from the single-database version - pattern_info/
pattern_count still index a single global pattern_map keyed by the
HS pattern id, because each shard’s patterns carry their ORIGINAL global
id, so a match from any shard maps back through the same table and the
scan output is the union of all shards in original-byte space.
§Examples
ⓘ
use keyhog_scanner::simd::backend::HsScanner;
let _scanner = HsScanner::compile(&[(0, 0, "demo_[A-Z0-9]{8}", false)])?;Implementations§
Source§impl HsScanner
impl HsScanner
Sourcepub fn compile(
patterns: &[(usize, usize, &str, bool)],
) -> Result<(Self, Vec<usize>), String>
pub fn compile( patterns: &[(usize, usize, &str, bool)], ) -> Result<(Self, Vec<usize>), String>
Sourcepub fn scan(&self, text: &[u8]) -> Vec<(usize, usize, usize)>
pub fn scan(&self, text: &[u8]) -> Vec<(usize, usize, usize)>
Scan text and return (hs_pattern_id, match_start, match_end).
Uses a scratch pool for thread-safety without per-call allocation.
§Examples
ⓘ
use keyhog_scanner::simd::backend::HsScanner;
let (scanner, _) = HsScanner::compile(&[(0, 0, "demo_[A-Z0-9]{8}", false)])?;
let _matches = scanner.scan(b"demo_ABC12345");Sourcepub fn pattern_count(&self) -> usize
pub fn pattern_count(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for HsScanner
impl Freeze for HsScanner
impl Unpin for HsScanner
impl UnsafeUnpin for HsScanner
impl UnwindSafe for HsScanner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more