Add serde feature and dependency for (de)serialization

This commit is contained in:
Moritz Hölting 2024-03-21 18:42:34 +01:00
parent f1484a7b66
commit 7997cd9213
2 changed files with 6 additions and 0 deletions

View File

@ -5,5 +5,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
serde = ["dep:serde"]
[dependencies]
serde = { version = "1.0.197", features = ["derive"], optional = true }
zip = "0.6.6"

View File

@ -11,6 +11,7 @@ use zip::ZipWriter;
/// Folder representation in virtual file system
#[derive(Debug, Default, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct VFolder {
folders: HashMap<String, VFolder>,
files: HashMap<String, VFile>,
@ -188,6 +189,7 @@ impl VFolder {
/// File representation in virtual file system
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum VFile {
/// Text file
Text(String),