use crate::{
input::{error::InputError, InputBlock, InputBlockIterator},
FallibleIterator, MaskType, BLOCK_SIZE,
};
pub type QuoteIterResult<I, M, const N: usize> = Result<Option<QuoteClassifiedBlock<I, M, N>>, InputError>;
pub struct QuoteClassifiedBlock<B, M, const N: usize> {
pub block: B,
pub within_quotes_mask: M,
}
pub struct ResumedQuoteClassifier<Q, B, M, const N: usize> {
pub classifier: Q,
pub first_block: Option<QuoteClassifiedBlock<B, M, N>>,
}
pub trait QuoteClassifiedIterator<'i, I: InputBlockIterator<'i, N>, M, const N: usize>:
FallibleIterator<Item = QuoteClassifiedBlock<I::Block, M, N>, Error = InputError>
{
fn get_offset(&self) -> usize;
fn offset(&mut self, count: isize) -> QuoteIterResult<I::Block, M, N>;
fn flip_quotes_bit(&mut self);
}
pub trait InnerIter<I> {
fn into_inner(self) -> I;
}
impl<'i, B, M, const N: usize> QuoteClassifiedBlock<B, M, N>
where
B: InputBlock<'i, N>,
{
#[must_use]
#[inline(always)]
pub fn len(&self) -> usize {
self.block.len()
}
#[must_use]
#[inline(always)]
pub fn is_empty(&self) -> bool {
self.block.is_empty()
}
}
pub(crate) mod nosimd;
pub(crate) mod shared;
#[cfg(target_arch = "x86")]
pub(crate) mod avx2_32;
#[cfg(target_arch = "x86_64")]
pub(crate) mod avx2_64;
#[cfg(target_arch = "x86_64")]
pub(crate) mod avx512_64;
#[cfg(target_arch = "aarch64")]
pub(crate) mod neon_64;
#[cfg(target_arch = "x86")]
pub(crate) mod sse2_32;
#[cfg(target_arch = "x86_64")]
pub(crate) mod sse2_64;
pub(crate) trait QuotesImpl {
type Classifier<'i, I>: QuoteClassifiedIterator<'i, I, MaskType, BLOCK_SIZE> + InnerIter<I>
where
I: InputBlockIterator<'i, BLOCK_SIZE>;
fn new<'i, I>(iter: I) -> Self::Classifier<'i, I>
where
I: InputBlockIterator<'i, BLOCK_SIZE>;
fn resume<'i, I>(
iter: I,
first_block: Option<I::Block>,
) -> ResumedQuoteClassifier<Self::Classifier<'i, I>, I::Block, MaskType, BLOCK_SIZE>
where
I: InputBlockIterator<'i, BLOCK_SIZE>;
}