rsonpath/classification/
memmem.rs1use crate::{
4 input::{error::InputError, Input},
5 result::InputRecorder,
6 string_pattern::StringPattern,
7 BLOCK_SIZE,
8};
9
10pub trait Memmem<'i, 'b, 'r, I: Input, const N: usize> {
12 fn find_label(
22 &mut self,
23 first_block: Option<I::Block<'i, N>>,
24 start_idx: usize,
25 label: &StringPattern,
26 ) -> Result<Option<(usize, I::Block<'i, N>)>, InputError>;
27}
28
29pub(crate) mod nosimd;
30pub(crate) mod shared;
31
32#[cfg(target_arch = "x86")]
33pub(crate) mod avx2_32;
34#[cfg(target_arch = "x86_64")]
35pub(crate) mod avx2_64;
36#[cfg(target_arch = "x86")]
37pub(crate) mod sse2_32;
38#[cfg(target_arch = "x86_64")]
39pub(crate) mod sse2_64;
40
41pub(crate) trait MemmemImpl {
42 type Classifier<'i, 'b, 'r, I, R>: Memmem<'i, 'b, 'r, I, BLOCK_SIZE>
43 where
44 I: Input + 'i,
45 <I as Input>::BlockIterator<'i, 'r, R, BLOCK_SIZE>: 'b,
46 R: InputRecorder<<I as Input>::Block<'i, BLOCK_SIZE>> + 'r,
47 'i: 'r;
48
49 fn memmem<'i, 'b, 'r, I, R>(
50 input: &'i I,
51 iter: &'b mut <I as Input>::BlockIterator<'i, 'r, R, BLOCK_SIZE>,
52 ) -> Self::Classifier<'i, 'b, 'r, I, R>
53 where
54 I: Input,
55 R: InputRecorder<<I as Input>::Block<'i, BLOCK_SIZE>>,
56 'i: 'r;
57}