pub mod bitmap;
pub mod filter;
pub mod range;

pub use bitmap::BitmapIndex;
pub use filter::{FilterError, FilterEvaluator, FilterExpr, FilterResult};
pub use range::RangeIndex;

/// Length of the fixed [`encode_key`](crate::storage::keys::encode_key) prefix
/// every persisted index key carries: 8 bytes entity ID + 1 NUL separator + 1
/// tag byte. The index parsers strip this prefix before matching their own
/// `BMP:` / `RNG:` suffix tag. Centralized here so the bitmap and range loaders
/// cannot drift to different literal offsets when the key layout changes.
pub(crate) const ENCODED_KEY_PREFIX_LEN: usize = 10;

/// Error type for index operations.
#[derive(Debug, thiserror::Error)]
pub enum IndexError {
    /// A storage-level error (e.g., I/O failure during persistence).
    #[error("storage error: {0}")]
    Storage(String),
    /// Serialization or deserialization failure.
    #[error("serialization error: {0}")]
    Serialization(String),
    /// A `FilterResult::Predicate` was supplied where a materialized bitmap
    /// was required. Predicate results cannot be losslessly converted to a
    /// bitmap without enumerating the entity universe; callers that need a
    /// bitmap must handle the predicate path explicitly.
    #[error("expected a bitmap filter result, found a predicate")]
    ExpectedBitmap,
}
