mod controller;
mod level_0;
mod level_1;
mod level_5;
mod parity;
mod exporter;

pub use controller::RaidController;
pub use level_0::Raid0;
pub use level_1::Raid1;
pub use level_5::Raid5;
pub use exporter::RaidExporter;

#[derive(Debug, Clone, Copy, PartialEq)]
pub enum RaidLevel {
    RAID0,
    RAID1,
    RAID5,
    RAID6,
    RAID10,
    RAID50,
    RAID60,
}

#[derive(Debug, Clone, Copy, PartialEq)]
pub enum MemberStatus {
    Online,
    Offline,
    Rebuilding,
    Failed,
}

pub type RaidError = Box<dyn std::error::Error + Send + Sync>;

pub trait RaidAlgorithm: Send + Sync {
    fn read(&mut self, block_offset: u64, size: u64) -> Result<Vec<u8>, RaidError>;
    fn write(&mut self, block_offset: u64, data: &[u8]) -> Result<(), RaidError>;
    fn get_total_size(&self) -> u64;
    fn get_level(&self) -> RaidLevel;
}