summaryrefslogtreecommitdiff
path: root/systems
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-02-24 18:56:01 +0800
committer魏曹先生 <1992414357@qq.com>2026-02-24 18:56:01 +0800
commitd319e7ea3b50875794a105435d6da5a8c653baed (patch)
tree74b99d3ae913e839a6946709addf6589847d4d30 /systems
parentcb8f366ede5e0d90ec716b0d06cfd2cbc863faff (diff)
fixup! Move sheet file R/W to v1 module
Diffstat (limited to 'systems')
-rw-r--r--systems/sheet/src/sheet/reader.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/systems/sheet/src/sheet/reader.rs b/systems/sheet/src/sheet/reader.rs
index 87347bb..583e3b7 100644
--- a/systems/sheet/src/sheet/reader.rs
+++ b/systems/sheet/src/sheet/reader.rs
@@ -1,3 +1,5 @@
+use constants::CURRENT_SHEET_VERSION;
+
use crate::{
mapping::{LocalMappingForward, Mapping},
sheet::{SheetData, error::ReadSheetDataError},
@@ -5,9 +7,22 @@ use crate::{
include!("current.rs");
+macro_rules! reader_do {
+ ($full_sheet_data:expr, $func:ident($($arg:expr),*)) => {{
+ let sheet_version = $full_sheet_data
+ .first()
+ .copied()
+ .unwrap_or(CURRENT_SHEET_VERSION);
+ match sheet_version {
+ 1 => crate::sheet::v1::reader::$func($($arg),*),
+ _ => reader::$func($($arg),*),
+ }
+ }};
+}
+
/// Reconstruct complete SheetData from full sheet data
pub fn read_sheet_data(full_sheet_data: &[u8]) -> Result<SheetData, ReadSheetDataError> {
- reader::read_sheet_data(full_sheet_data)
+ reader_do!(full_sheet_data, read_sheet_data(full_sheet_data))
}
/// Read mapping information for a specific node from complete sheet data
@@ -15,5 +30,5 @@ pub fn read_mapping<'a>(
full_sheet_data: &'a [u8],
node: &[&str],
) -> Result<Option<(Mapping<'a>, LocalMappingForward)>, ReadSheetDataError> {
- reader::read_mapping(full_sheet_data, node)
+ reader_do!(full_sheet_data, read_mapping(full_sheet_data, node))
}