PatchSet only serializes patches to the file.
				
					
				
			This commit is contained in:
		
							parent
							
								
									4cbc70eeca
								
							
						
					
					
						commit
						975d6fd420
					
				
					 2 changed files with 17 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -24,7 +24,6 @@ pub struct Patch {
 | 
			
		|||
    pub patch_data: Vec<u8>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Deserialize, Serialize)]
 | 
			
		||||
pub struct PatchSet {
 | 
			
		||||
    filename: PathBuf,
 | 
			
		||||
    patches: Vec<Patch>,
 | 
			
		||||
| 
						 | 
				
			
			@ -43,6 +42,22 @@ impl PatchSet {
 | 
			
		|||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn save(&self) -> anyhow::Result<()> {
 | 
			
		||||
        let file = File::create(&self.filename)?;
 | 
			
		||||
        let buffer = std::io::BufWriter::new(file);
 | 
			
		||||
        serde_json::to_writer(buffer, &self.patches)?;
 | 
			
		||||
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn save_to_file(&self, filename: &Path) -> anyhow::Result<()> {
 | 
			
		||||
        let file = File::create(filename)?;
 | 
			
		||||
        let buffer = std::io::BufWriter::new(file);
 | 
			
		||||
        serde_json::to_writer(buffer, &self.patches)?;
 | 
			
		||||
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn add_patch(&mut self, patch: Patch) {
 | 
			
		||||
        self.patches.push(patch);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue