Fix up compiler issues.
This commit is contained in:
parent
5f8f1b5655
commit
c81348fb10
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -13,7 +13,7 @@ name = "bin_comp"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde",
|
||||
"enemize",
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
]
|
||||
|
@ -31,10 +31,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "enemize-rs"
|
||||
name = "enemize"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"md5",
|
||||
"anyhow",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
[package]
|
||||
name = "enemize-rs"
|
||||
name = "enemize"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = 1.0, features = ["derive"] }
|
||||
anyhow = "1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
|
|
@ -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…
Reference in a new issue