use std::io;
use thiserror::Error;
pub type Result<T, E = HFileError> = std::result::Result<T, E>;
#[derive(Error, Debug)]
pub enum HFileError {
#[error("Invalid HFile: {0}")]
InvalidFormat(String),
#[error("Invalid block magic: expected {expected}, got {actual}")]
InvalidBlockMagic { expected: String, actual: String },
#[error("Unsupported HFile version: major={major}, minor={minor}")]
UnsupportedVersion { major: u32, minor: u32 },
#[error("Unsupported compression codec: {0}")]
UnsupportedCompression(u32),
#[error("HFiles with MVCC timestamps are not supported")]
UnsupportedMvccTimestamp,
#[error("Decompression error: {0}")]
DecompressionError(String),
#[error("Protobuf decode error: {0}")]
ProtobufError(#[from] prost::DecodeError),
#[error("IO error: {0}")]
IoError(#[from] io::Error),
#[error("Unexpected block type: expected {expected}, got {actual}")]
UnexpectedBlockType { expected: String, actual: String },
#[error("Backward seek not supported: current position is ahead of lookup key")]
BackwardSeekNotSupported,
#[error("Not seeked: must call seek_to() before reading key-value pairs")]
NotSeeked,
#[error("End of file reached")]
Eof,
}