use std::path::PathBuf;

#[derive(Debug, Clone)]
pub struct BtrfsFilesystem {
    pub label: String,
    pub uuid: String,
    pub mount_path: Option<PathBuf>,
    pub is_mounted: bool,
}

#[derive(Debug, Clone)]
pub struct BtrfsSubvolume {
    pub id: u64,
    pub path: PathBuf,
    pub name: String,
    pub uuid: Option<String>,
    pub parent_id: Option<u64>,
    pub top_level_id: u64,
    pub generation: u64,
    pub gen_at_creation: Option<u64>,
    pub creation_time: Option<String>,
}

#[derive(Debug, Clone)]
pub struct BtrfsSubvolumeEntry {
    pub id: u64,
    pub generation: u64,
    pub top_level: u64,
    pub path: String,
}

#[derive(Debug, Clone)]
pub struct SubvolumeUsage {
    pub subvolume_id: u64,
    pub usage: u64,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DeviceType {
    SSD,
    HDD,
}

impl DeviceType {
    pub fn from_str(s: &str) -> Option<Self> {
        match s.to_uppercase().as_str() {
            "SSD" => Some(DeviceType::SSD),
            "HDD" => Some(DeviceType::HDD),
            _ => None,
        }
    }

    pub fn as_str(&self) -> &'static str {
        match self {
            DeviceType::SSD => "SSD",
            DeviceType::HDD => "HDD",
        }
    }
}

#[derive(Debug, Clone)]
pub struct FilesystemUsage {
    pub total: u64,
    pub used: u64,
    pub available: u64,
}

#[derive(Debug, Clone)]
pub struct FilesystemBlockGroup {
    pub bg_type: String,
    pub bg_profile: String,
    pub total: u64,
    pub used: u64,
}

#[derive(Debug, Clone)]
pub struct GroupUsage {
    pub profile: String,
    pub total: u64,
    pub used: u64,
}

#[derive(Debug, Clone)]
pub struct FilesystemUsageStructured {
    pub data: GroupUsage,
    pub metadata: GroupUsage,
    pub system: GroupUsage,
    pub globalreserved: GroupUsage,
}

#[derive(Debug, Clone)]
pub struct QuotaGroup {
    pub qgroupid: String,
    pub referenced: u64,
    pub max_referenced: Option<u64>,
    pub exclusive: u64,
    pub max_exclusive: Option<u64>,
    pub path: String,
    pub parents: Vec<String>,
    pub children: Vec<String>,
}

#[derive(Debug, Clone)]
pub struct SubvolumeMetadata {
    pub id: u64,
    pub path: PathBuf,
    pub name: String,
}

#[derive(Debug, Clone)]
pub struct SubvolumeInfo {
    pub id: u64,
    pub path: PathBuf,
    pub name: String,
    pub uuid: Option<String>,
    pub parent_id: Option<u64>,
    pub top_level_id: u64,
    pub generation: u64,
    pub gen_at_creation: Option<u64>,
    pub creation_time: Option<String>,
}
