Moved known/foreign data/func loading into the executable.

Slightly revised the data / func table interface.
This commit is contained in:
2021-04-29 16:36:27 +01:00
parent 4b559b7ce1
commit 3eed1e930a
10 changed files with 366 additions and 317 deletions

View File

@@ -1,7 +1,7 @@
//! Errors
// Imports
use crate::{func, header};
use crate::header;
/// Error type for [`ExeReader::deserialize`](super::ExeReader::deserialize)
#[derive(Debug, thiserror::Error)]
@@ -21,32 +21,4 @@ pub enum DeserializeError {
/// Unable to read data
#[error("Unable to read data")]
ReadData(#[source] std::io::Error),
/// Unable to get known data
#[error("Unable to get known data table")]
KnownDataTable(#[source] GetKnownError),
/// Unable to get known data
#[error("Unable to get known func table")]
KnownFuncTable(#[source] func::table::GetKnownError),
}
/// Error type for getting the known function table
#[derive(Debug, thiserror::Error)]
pub enum GetKnownError {
/// Unable to open game data file
#[error("Unable to open game data file")]
OpenGame(#[source] std::io::Error),
/// Unable to parse game data file
#[error("Unable to parse game data file")]
ParseGame(#[source] serde_yaml::Error),
/// Unable to open foreign data file
#[error("Unable to open foreign data file")]
OpenForeign(#[source] std::io::Error),
/// Unable to parse foreign data file
#[error("Unable to parse foreign data file")]
ParseForeign(#[source] serde_yaml::Error),
}

View File

@@ -75,7 +75,7 @@ impl<'a> Iterator for Iter<'a> {
return Some(ExeItem::Data {
data,
insts: self.exe.parse_iter_from(cur_pos..end_pos),
insts: self.exe.decode_iter(cur_pos..end_pos),
});
}
@@ -84,7 +84,7 @@ impl<'a> Iterator for Iter<'a> {
self.cur_pos = func.end_pos;
return Some(ExeItem::Func {
func,
insts: self.exe.parse_iter_from(cur_pos..func.end_pos),
insts: self.exe.decode_iter(cur_pos..func.end_pos),
});
}
@@ -108,7 +108,7 @@ impl<'a> Iterator for Iter<'a> {
Some(ExeItem::Unknown {
insts: self.exe.parse_iter_from(cur_pos..end_pos),
insts: self.exe.decode_iter(cur_pos..end_pos),
})
}
}

View File

@@ -0,0 +1,14 @@
//! Deserialization options
// Imports
use crate::{DataTable, FuncTable};
/// Options for deserialization
#[derive(Default, Debug)]
pub struct DeserializeOpts {
/// Existing data table to use
pub data_table: Option<DataTable>,
/// Existing function table to use
pub func_table: Option<FuncTable>,
}