diff --git a/Cargo.toml b/Cargo.toml index a310220..4789914 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/virtual_fs.rs b/src/virtual_fs.rs index 920d25a..acce10d 100644 --- a/src/virtual_fs.rs +++ b/src/virtual_fs.rs @@ -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, files: HashMap, @@ -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),