use crate::{
input::{error::InputError, Input},
query::JsonString,
result::InputRecorder,
BLOCK_SIZE,
};
use cfg_if::cfg_if;
pub trait Memmem<'i, 'b, 'r, I: Input, const N: usize> {
fn find_label(
&mut self,
first_block: Option<I::Block<'i, N>>,
start_idx: usize,
label: &JsonString,
) -> Result<Option<(usize, I::Block<'i, N>)>, InputError>;
}
cfg_if! {
if #[cfg(any(doc, not(feature = "simd")))] {
mod nosimd;
type MemmemImpl<'a, 'b, 'r, I, R> = nosimd::SequentialMemmemClassifier<'a, 'b, 'r, I, R, BLOCK_SIZE>;
}
else if #[cfg(simd = "avx2")] {
mod avx2;
type MemmemImpl<'a, 'b, 'r, I, R> = avx2::Avx2MemmemClassifier<'a, 'b, 'r, I, R>;
}
else {
compile_error!("Target architecture is not supported by SIMD features of this crate. Disable the default `simd` feature.");
}
}
#[must_use]
#[inline(always)]
pub fn memmem<'i, 'b, 'r, I, R>(
input: &'i I,
iter: &'b mut I::BlockIterator<'i, 'r, BLOCK_SIZE, R>,
) -> impl Memmem<'i, 'b, 'r, I, BLOCK_SIZE>
where
I: Input,
R: InputRecorder<I::Block<'i, BLOCK_SIZE>>,
'i: 'r,
{
MemmemImpl::new(input, iter)
}