macro_rules! failpoint {
($stage:ident) => {
#[cfg(any(test, feature = "test-faults"))]
$crate::seg::failpoints::hit($crate::seg::failpoints::$stage);
};
}
pub(crate) use failpoint;
pub(crate) mod block;
pub(crate) mod cache;
pub(crate) mod config;
pub(crate) mod core;
#[cfg(any(test, feature = "test-faults"))]
#[doc(hidden)]
pub mod failpoints;
pub(crate) mod filter;
pub(crate) mod freeze;
pub(crate) mod fs;
pub(crate) mod generation;
pub(crate) mod hash;
pub(crate) mod index_migration;
pub(crate) mod index_target;
pub(crate) mod key_index;
pub(crate) mod manifest;
pub(crate) mod map;
#[cfg(test)]
#[cfg(feature = "segmented")]
mod model_tests;
pub(crate) mod ordered;
#[cfg(test)]
mod ordered_tests;
pub(crate) mod page_index;
pub(crate) mod projections;
pub(crate) mod query;
pub(crate) mod residency;
pub(crate) mod scan;
#[cfg(test)]
mod scenario_tests;
pub(crate) mod seal;
pub(crate) mod segment;
pub(crate) mod sidecar;
pub(crate) mod skeleton;
#[cfg(test)]
pub(crate) mod testkit;
pub(crate) mod tree;
pub(crate) mod verify;
pub(crate) mod worker;
pub use config::SegConfig;
pub use core::SegMeta;
pub use index_target::IndexState;
pub use map::SegMap;
pub use query::SegRange;
pub use tree::{SegIter, SegKeyIter, SegTree, SegTreeMeta};
pub use verify::{SegStats, SegmentInfo, VerifyProblem, VerifyReport, VerifyScope};
pub use worker::SealStatus;
use std::path::Path;
use crate::error::DbError;
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum FormatFault {
Unsupported(String),
Corrupt(String),
}
impl FormatFault {
pub(crate) fn unsupported(msg: impl Into<String>) -> Self {
Self::Unsupported(msg.into())
}
pub(crate) fn corrupt(msg: impl Into<String>) -> Self {
Self::Corrupt(msg.into())
}
pub(crate) fn into_db(self, segment_id: u64, block: Option<u32>, path: &Path) -> DbError {
match self {
Self::Unsupported(reason) => {
DbError::FormatMismatch(format!("{}: {reason}", path.display()))
}
Self::Corrupt(reason) => DbError::SegmentCorrupt {
segment_id,
block,
path: path.to_path_buf(),
reason,
},
}
}
}