Add the logic which will call disk image conversion from disk image route
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-05-29 11:37:11 +02:00
parent e7ac0198ab
commit e017fe96d5
10 changed files with 279 additions and 13 deletions

View File

@ -13,15 +13,32 @@ enum DisksError {
Create,
}
#[derive(Debug, serde::Serialize)]
#[derive(Debug, serde::Serialize, serde::Deserialize, Copy, Clone)]
#[serde(tag = "format")]
pub enum DiskFileFormat {
Raw { is_sparse: bool },
QCow2 { virtual_size: FileSize },
Raw {
#[serde(default)]
is_sparse: bool,
},
QCow2 {
#[serde(default)]
virtual_size: FileSize,
},
CompressedRaw,
CompressedQCow2,
}
impl DiskFileFormat {
pub fn ext(&self) -> &'static [&'static str] {
match self {
DiskFileFormat::Raw { .. } => &["", "raw"],
DiskFileFormat::QCow2 { .. } => &["qcow2"],
DiskFileFormat::CompressedRaw => &["raw.gz"],
DiskFileFormat::CompressedQCow2 => &["qcow2.gz"],
}
}
}
/// Disk file information
#[derive(serde::Serialize)]
pub struct DiskFileInfo {
@ -125,6 +142,11 @@ impl DiskFileInfo {
Ok(())
}
/// Copy / convert file disk image into a new destination with optionally a new file format
pub fn convert(&self, dest_file: &Path, dest_format: DiskFileFormat) -> anyhow::Result<()> {
todo!()
}
}
#[derive(serde::Deserialize)]