Fix up compiler issues.
This commit is contained in:
		
							parent
							
								
									5f8f1b5655
								
							
						
					
					
						commit
						c81348fb10
					
				
					 3 changed files with 22 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -1,40 +1,40 @@
 | 
			
		|||
use std::io::Read;
 | 
			
		||||
use std::fs::File;
 | 
			
		||||
use std::path::{Path, PathBuf};
 | 
			
		||||
 | 
			
		||||
use serde::Serialize;
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
 | 
			
		||||
pub mod rom;
 | 
			
		||||
 | 
			
		||||
#[derive(Serialize)]
 | 
			
		||||
#[derive(Deserialize, Serialize)]
 | 
			
		||||
pub struct Patch {
 | 
			
		||||
    pub address: usize,
 | 
			
		||||
    pub patch_data: Vec<u8>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Serialize)]
 | 
			
		||||
#[derive(Deserialize, Serialize)]
 | 
			
		||||
pub struct PatchSet {
 | 
			
		||||
    filename: PathBuf,
 | 
			
		||||
    patches: Vec<Patch>
 | 
			
		||||
    patches: Vec<Patch>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl PatchSet {
 | 
			
		||||
    pub fn load(filename: Path) -> Result<PatchSet, anyhow::Error> {
 | 
			
		||||
    pub fn load(filename: &Path) -> Result<PatchSet, anyhow::Error> {
 | 
			
		||||
        let patches = {
 | 
			
		||||
            let mut file = File::open(filename)?;
 | 
			
		||||
            let mut buffer = std::io::BufReader::new(file);
 | 
			
		||||
            let file = File::open(filename)?;
 | 
			
		||||
            let buffer = std::io::BufReader::new(file);
 | 
			
		||||
            serde_json::from_reader(buffer)?
 | 
			
		||||
        };
 | 
			
		||||
        PatchSet {
 | 
			
		||||
        Ok(PatchSet {
 | 
			
		||||
            filename: filename.into(),
 | 
			
		||||
            patches: patches
 | 
			
		||||
        }
 | 
			
		||||
            patches: patches,
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn filename(&self) -> Path {
 | 
			
		||||
    pub fn filename(&self) -> &Path {
 | 
			
		||||
        self.filename.as_path()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn patchRom(&self, &mut rom: RomData) {
 | 
			
		||||
    pub fn patch_rom(self, rom: &mut RomData) {
 | 
			
		||||
        for patch in self.patches {
 | 
			
		||||
            rom.patch_data(patch);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue