use std::io;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ShamirError {
#[error("Invalid threshold value {0}")]
InvalidThreshold(u8),
#[error("Invalid share count {0}")]
InvalidShareCount(u8),
#[error("Threshold {threshold} exceeds total shares {total_shares}")]
ThresholdTooLarge { threshold: u8, total_shares: u8 },
#[error("Need at least {needed} shares, got {got}")]
InsufficientShares { needed: u8, got: u8 },
#[error("Invalid share index {0}")]
InvalidShareIndex(u8),
#[error("I/O error: {0}")]
IoError(#[from] io::Error),
#[error("Data integrity check failed")]
IntegrityCheckFailed,
#[error("Invalid share format")]
InvalidShareFormat,
#[error("Inconsistent share lengths")]
InconsistentShareLength,
#[cfg(feature = "compress")]
#[error("Compression error: {0}")]
CompressionError(String),
#[cfg(feature = "compress")]
#[error("Decompression error: {0}")]
DecompressionError(String),
#[error("Invalid configuration: {0}")]
InvalidConfig(String),
#[error("Storage error: {0}")]
StorageError(String),
}
pub type Result<T> = std::result::Result<T, ShamirError>;