summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--systems/sheet/Cargo.toml2
-rw-r--r--systems/sheet/src/index_source.rs4
-rw-r--r--systems/sheet/src/mapping.rs7
-rw-r--r--systems/sheet/src/sheet.rs9
5 files changed, 15 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ba67bd3..88a8d1d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1481,6 +1481,7 @@ dependencies = [
"hex_display",
"just_fmt",
"memmap2",
+ "serde",
"sha2 0.10.9",
"sheet_system_macros",
"thiserror 1.0.69",
diff --git a/systems/sheet/Cargo.toml b/systems/sheet/Cargo.toml
index 657c567..007074b 100644
--- a/systems/sheet/Cargo.toml
+++ b/systems/sheet/Cargo.toml
@@ -10,6 +10,8 @@ constants = { path = "../_constants" }
sheet_system_macros = { path = "macros" }
asset_system = { path = "../_asset" }
+serde = "1"
+
tokio = { version = "1.48", features = ["full"] }
thiserror = "1.0.69"
diff --git a/systems/sheet/src/index_source.rs b/systems/sheet/src/index_source.rs
index a2fc43d..b22f5a6 100644
--- a/systems/sheet/src/index_source.rs
+++ b/systems/sheet/src/index_source.rs
@@ -1,6 +1,8 @@
+use serde::{Deserialize, Serialize};
+
/// IndexSource
/// Points to a unique resource address in Vault
-#[derive(Debug, Clone, Copy)]
+#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct IndexSource {
/// The index ID of the resource
id: u32,
diff --git a/systems/sheet/src/mapping.rs b/systems/sheet/src/mapping.rs
index 1743534..b2acaa7 100644
--- a/systems/sheet/src/mapping.rs
+++ b/systems/sheet/src/mapping.rs
@@ -1,4 +1,5 @@
use just_fmt::fmt_path::{PathFormatConfig, fmt_path_str, fmt_path_str_custom};
+use serde::{Deserialize, Serialize};
use crate::{index_source::IndexSource, mapping::error::ParseMappingError};
@@ -11,7 +12,7 @@ pub mod error;
/// Local mapping
/// It is stored inside a Sheet and will be exposed externally as Mapping or MappingBuf
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LocalMapping {
/// The value of the local mapping
val: Vec<String>,
@@ -25,7 +26,7 @@ pub struct LocalMapping {
/// The forward direction of the current Mapping
/// It indicates the expected asset update method for the current Mapping
-#[derive(Default, Debug, PartialEq, Eq, Clone)]
+#[derive(Default, Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum LocalMappingForward {
/// Expect the current index version to be the latest
#[default]
@@ -51,7 +52,7 @@ pub struct Mapping<'a> {
/// MappingBuf
/// It stores complete mapping information and participates in complex mapping editing operations like storage and modification
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct MappingBuf {
sheet_name: String,
val: Vec<String>,
diff --git a/systems/sheet/src/sheet.rs b/systems/sheet/src/sheet.rs
index e0275cb..e169e4e 100644
--- a/systems/sheet/src/sheet.rs
+++ b/systems/sheet/src/sheet.rs
@@ -6,6 +6,7 @@ use std::{
};
use memmap2::Mmap;
+use serde::{Deserialize, Serialize};
use tokio::fs;
use crate::{
@@ -25,7 +26,7 @@ pub mod writer;
// Format
pub mod v1;
-#[derive(Default, Debug, Clone, PartialEq)]
+#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Sheet {
/// Sheet Name
name: String,
@@ -40,7 +41,7 @@ pub struct Sheet {
/// Full Sheet information
///
/// Used to wrap as a Sheet object for editing and persistence
-#[derive(Default, Debug, Clone, PartialEq, Eq)]
+#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SheetData {
/// All local mappings
mappings: HashSet<LocalMapping>,
@@ -55,7 +56,7 @@ pub struct SheetDataMmap {
///
/// Stored in the Sheet, records the editing operations that **will** be performed on its SheetData
/// The content will be cleared after the edits are applied
-#[derive(Default, Debug, Clone, PartialEq)]
+#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SheetEdit {
/// Edit history
list: Vec<SheetEditItem>,
@@ -76,7 +77,7 @@ impl SheetEdit {
}
}
-#[derive(Default, Debug, Clone, PartialEq)]
+#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum SheetEditItem {
/// Do nothing, this entry is not included in checksum and audit
#[default]