Add the logic which will call disk image conversion from disk image route
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			This commit is contained in:
		@@ -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)]
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,14 @@
 | 
			
		||||
#[derive(
 | 
			
		||||
    serde::Serialize, serde::Deserialize, Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord,
 | 
			
		||||
    serde::Serialize,
 | 
			
		||||
    serde::Deserialize,
 | 
			
		||||
    Copy,
 | 
			
		||||
    Clone,
 | 
			
		||||
    Debug,
 | 
			
		||||
    Eq,
 | 
			
		||||
    PartialEq,
 | 
			
		||||
    PartialOrd,
 | 
			
		||||
    Ord,
 | 
			
		||||
    Default,
 | 
			
		||||
)]
 | 
			
		||||
pub struct FileSize(usize);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user