use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum PerCoreWalError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Deserialization error: {0}")]
Deserialization(String),
#[error("CRC32 checksum mismatch at position {position} in segment {core_id}: expected {expected:#010x}, got {actual:#010x}")]
ChecksumMismatch {
core_id: usize,
position: u64,
expected: u32,
actual: u32,
},
#[error("Torn write detected at position {position} in segment {core_id}: {reason}")]
TornWrite {
core_id: usize,
position: u64,
reason: String,
},
#[error("Corrupted WAL entry at position {position} in segment {core_id}: {reason}")]
Corrupted {
core_id: usize,
position: u64,
reason: String,
},
#[error("Invalid core ID {core_id}: max is {max_core_id}")]
InvalidCoreId {
core_id: usize,
max_core_id: usize,
},
#[error("Segment file not found for core {core_id}: {path}")]
SegmentNotFound {
core_id: usize,
path: PathBuf,
},
#[error("Checkpoint not found at {path}")]
CheckpointNotFound {
path: PathBuf,
},
#[error("Recovery failed: {0}")]
RecoveryFailed(String),
#[error("Writer for core {0} not initialized")]
WriterNotInitialized(usize),
#[error("Epoch mismatch: expected {expected}, got {actual}")]
EpochMismatch {
expected: u64,
actual: u64,
},
#[error("Incremental checkpoint error: {0}")]
IncrementalCheckpoint(#[from] crate::incremental::IncrementalCheckpointError),
}