From cf2fa3030a88a79691e417f1bdc87d3064587ebe Mon Sep 17 00:00:00 2001 From: endernon Date: Sat, 23 Nov 2024 14:19:34 +0000 Subject: [PATCH] actually set up serde correctly --- Cargo.lock | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 2 +- src/lib.rs | 52 +++++++++++++++++++++++----------------------- 3 files changed, 85 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0246751..05fb5ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,62 @@ version = 3 [[package]] name = "mcmeta-parser" -version = "0.1.0" +version = "0.4.0" +dependencies = [ + "serde", +] + +[[package]] +name = "proc-macro2" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "2.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" diff --git a/Cargo.toml b/Cargo.toml index e7829b4..68e63b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,4 @@ version = "0.4.0" edition = "2021" [dependencies] -serde="1.0.215" \ No newline at end of file +serde={ version = "1.0.215", features = ["derive"] } diff --git a/src/lib.rs b/src/lib.rs index d1e0c07..40083f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,66 +1,64 @@ use serde::{Serialize,Deserialize}; #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] -#[serde()] -pub struct McMeta { - pub pack: McMeta_Pack, - pub features: McMeta_Features, - pub filter: Option, - pub overlays: Option, - pub language: Option> +pub struct Mcmeta { + pub pack: McmetaPack, + pub features: McmetaFeatures, + pub filter: Option, + pub overlays: Option, + pub language: Option> } - #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Pack { - pub description: Vec, + pub struct McmetaPack { + pub description: Vec, pub pack_format: u8, - pub supported_formats: Option + pub supported_formats: Option } #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Pack_Description_Vec { + pub struct McmetaPackDescription { pub text: String, pub color: Option } #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Pack_SupportedFormats { + pub struct McmetaPackSupportedformats { pub min_inclusive: u8, pub max_inclusive: u8 } // I don't actually know wtf this looks like. I'm guessing based on minecraft wiki #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Features { + pub struct McmetaFeatures { pub enabled: Vec } // I don't what this looks like either #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Filter { - pub block: Vec + pub struct McmetaFilter { + pub block: Vec } #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Filter_Block_Vec { + pub struct McmetaFilterBlock { pub Namespace: String, pub Path: String } #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Overlays { - pub entries: Vec + pub struct McmetaOverlays { + pub entries: Vec } #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Overlays_Entries { - pub formats: McMeta_Overlays_Entries_Formats, + pub struct McmetaOverlaysEntries { + pub formats: McmetaOverlaysEntriesFormats, pub directory: String } - #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Overlays_Entries_Formats { - pub min_inclusive: u8, - pub max_inclusive: u8 - } + #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] + pub struct McmetaOverlaysEntriesFormats { + pub min_inclusive: u8, + pub max_inclusive: u8 + } #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] - pub struct McMeta_Language_Vec { + pub struct McmetaLanguage { pub name: String, pub region: String, pub bidirectional: bool