mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-14 21:47:47 +00:00
Moved known/foreign data/func loading into the executable.
Slightly revised the data / func table interface.
This commit is contained in:
@@ -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),
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
14
dcb-exe/src/reader/opts.rs
Normal file
14
dcb-exe/src/reader/opts.rs
Normal 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>,
|
||||
}
|
||||
Reference in New Issue
Block a user