#![doc = include_str!("../README.md")]
use std::{collections::TryReserveError, io};
pub use aliases::SharedAlias;
pub use builder::Builder;
pub use coverage::{Coverage, CoverageRouter};
#[cfg(feature = "external-sort")]
pub use external::{ExternalBuildStats, ExternalBuilder, ExternalOptions};
pub use reader::{
BatchError, Inspection, Match, PayloadReferences, Query, Reader, SectionEncoding,
SectionInspection,
};
pub use reader_set::ReaderSet;
pub use target::Target;
mod aliases;
mod broad_routes;
mod builder;
#[cfg(feature = "codec")]
pub mod codec;
mod coverage;
#[cfg(feature = "external-sort")]
mod external;
mod layout;
#[cfg(feature = "mmdb")]
pub mod mmdb;
mod packed;
mod payload;
mod reader;
mod reader_set;
mod search;
mod target;
#[cfg(feature = "shared-values")]
pub mod values;
#[cfg(feature = "mmap")]
pub type MappedReader = Reader<memmap2::Mmap>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("resource limit exceeded: {0}")]
Limit(&'static str),
#[error("invalid {0}")]
Invalid(&'static str),
#[cfg(feature = "codec")]
#[error("invalid codec field {position}: {reason}")]
CodecField {
position: usize,
reason: &'static str,
},
#[cfg(feature = "shared-values")]
#[error("invalid shared string UTF-8")]
Utf8(#[from] std::str::Utf8Error),
#[error("unsupported index version {0}")]
Version(u32),
#[error("failed to reserve index memory")]
Allocation(#[from] TryReserveError),
#[error("failed to reserve deduplication table memory")]
HashAllocation(#[from] hashbrown::TryReserveError),
#[cfg(feature = "mmap")]
#[error("failed to {operation} index file")]
MappingIo {
operation: &'static str,
#[source]
error: io::Error,
},
#[error("artifact I/O failed")]
Io(#[from] io::Error),
#[cfg(feature = "external-sort")]
#[error("failed to {operation} temporary index data")]
TemporaryIo {
operation: &'static str,
#[source]
error: io::Error,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Limits {
pub records: usize,
pub bytes: usize,
}
impl Default for Limits {
fn default() -> Self {
Self {
records: 1_000_000,
bytes: 128 * 1024 * 1024,
}
}
}