pub trait MatchScan {
// Required methods
fn scan(
&self,
backend: &dyn VyreBackend,
haystack: &[u8],
max_matches: u32,
) -> Result<Vec<Match>, BackendError>;
fn reference_scan(&self, haystack: &[u8]) -> Vec<Match>;
fn cache_key(&self) -> String;
// Provided method
fn try_reference_scan(
&self,
haystack: &[u8],
) -> Result<Vec<Match>, BackendError> { ... }
}Expand description
GPU + Reference scan operations exposed by every matcher in this crate.
Object-safe (dyn MatchScan is valid) so consumers can hold a heap-
allocated trait object and swap engines at runtime.
Required Methods§
Sourcefn scan(
&self,
backend: &dyn VyreBackend,
haystack: &[u8],
max_matches: u32,
) -> Result<Vec<Match>, BackendError>
fn scan( &self, backend: &dyn VyreBackend, haystack: &[u8], max_matches: u32, ) -> Result<Vec<Match>, BackendError>
GPU dispatch through a concrete backend, returning up to
max_matches matches. Engines pre-allocate the hit buffer at
max_matches * 3 + 1 u32 slots; setting this too low silently
truncates results.
Sourcefn reference_scan(&self, haystack: &[u8]) -> Vec<Match>
fn reference_scan(&self, haystack: &[u8]) -> Vec<Match>
Reference oracle scan. Used by the cross-layer parity tests in
vyre-conform; engines that lack a meaningful CPU stepper
(none today) can return an empty vec but should never fabricate
results.
Engines whose CPU stepper can fail (e.g. a haystack exceeding the
u32 match ABI) must abort loudly here rather than returning an empty
vec, an empty result is a silent recall lie (Law 10). Such engines
override Self::try_reference_scan so dyn MatchScan consumers can
recover the error instead of unwinding.
Sourcefn cache_key(&self) -> String
fn cache_key(&self) -> String
Stable identity for cache filenames + telemetry. Engines hash
their pattern set + version constant. Consumers pass this
straight to cached_load_or_compile without further hashing.
Provided Methods§
Sourcefn try_reference_scan(
&self,
haystack: &[u8],
) -> Result<Vec<Match>, BackendError>
fn try_reference_scan( &self, haystack: &[u8], ) -> Result<Vec<Match>, BackendError>
Fallible reference oracle scan. Surfaces a CPU-stepper failure (a
haystack longer than the u32 match ABI the GPU path uses) as an error
instead of aborting, so consumers holding dyn MatchScan can recover.
The default delegates to the infallible Self::reference_scan for
engines whose stepper genuinely cannot fail; engines with a fallible
stepper override this to forward to their real fallible scan (and never
route through the panicking infallible wrapper).
§Errors
Engine-specific vyre::BackendError when the CPU oracle cannot honor
the same u32 match ABI the GPU path uses for this haystack.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".