From 928953d58e119168ccb105c315e9183ca73c908b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 12 Jan 2024 18:07:04 +0800 Subject: [PATCH] move! --- Cargo.lock | 98 ------------------------------------ Cargo.toml => v1/Cargo.toml | 0 LICENSE => v1/LICENSE | 0 {src => v1/src}/data.rs | 0 {src => v1/src}/main.rs | 0 {src => v1/src}/read.rs | 0 {src => v1/src}/rustfmt.toml | 0 v2/Cargo.toml | 8 +++ v2/src/data_struct.rs | 29 +++++++++++ v2/src/main.rs | 5 ++ 10 files changed, 42 insertions(+), 98 deletions(-) delete mode 100644 Cargo.lock rename Cargo.toml => v1/Cargo.toml (100%) rename LICENSE => v1/LICENSE (100%) rename {src => v1/src}/data.rs (100%) rename {src => v1/src}/main.rs (100%) rename {src => v1/src}/read.rs (100%) rename {src => v1/src}/rustfmt.toml (100%) create mode 100644 v2/Cargo.toml create mode 100644 v2/src/data_struct.rs create mode 100644 v2/src/main.rs diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 96145fb..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,98 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - -[[package]] -name = "fastnbt" -version = "2.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3369bd70629bccfda7e344883c9ae3ab7f3b10a357bcf8b0f69caa7256bcf188" -dependencies = [ - "byteorder", - "cesu8", - "serde", - "serde_bytes", -] - -[[package]] -name = "nbt-rust" -version = "0.1.0" -dependencies = [ - "fastnbt", -] - -[[package]] -name = "proc-macro2" -version = "1.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "serde" -version = "1.0.181" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3e73c93c3240c0bda063c239298e633114c69a888c3e37ca8bb33f343e9890" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_bytes" -version = "0.11.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.181" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be02f6cb0cd3a5ec20bbcfbcbd749f57daddb1a0882dc2e46a6c236c90b977ed" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "syn" -version = "2.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" diff --git a/Cargo.toml b/v1/Cargo.toml similarity index 100% rename from Cargo.toml rename to v1/Cargo.toml diff --git a/LICENSE b/v1/LICENSE similarity index 100% rename from LICENSE rename to v1/LICENSE diff --git a/src/data.rs b/v1/src/data.rs similarity index 100% rename from src/data.rs rename to v1/src/data.rs diff --git a/src/main.rs b/v1/src/main.rs similarity index 100% rename from src/main.rs rename to v1/src/main.rs diff --git a/src/read.rs b/v1/src/read.rs similarity index 100% rename from src/read.rs rename to v1/src/read.rs diff --git a/src/rustfmt.toml b/v1/src/rustfmt.toml similarity index 100% rename from src/rustfmt.toml rename to v1/src/rustfmt.toml diff --git a/v2/Cargo.toml b/v2/Cargo.toml new file mode 100644 index 0000000..4ad2937 --- /dev/null +++ b/v2/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "shen-nbt2" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/v2/src/data_struct.rs b/v2/src/data_struct.rs new file mode 100644 index 0000000..d38da68 --- /dev/null +++ b/v2/src/data_struct.rs @@ -0,0 +1,29 @@ +use std::collections::HashMap; + +/// NBT 里除了字符串的长度量都是 i32 +pub type NbtLength = i32; + +/// NBT 里的字符串独树一帜的把自己的长度用一个u32表示 +/// 不如说为啥别的不用 u32 呢 +pub type StringLength = u16; + + +pub struct RawData<'data> { + pub raw_data: &'data [u8], +} + + +pub enum Value<'value> { + Byte(RawData<'value>), + Short(RawData<'value>), + Int(RawData<'value>), + Long(RawData<'value>), + Float(RawData<'value>), + Double(RawData<'value>), + String(RawData<'value>), + ByteArray(RawData<'value>), + IntArray(RawData<'value>), + LongArray(RawData<'value>), + List(Vec>), + Compound(HashMap<&'value str, Value<'value>>), +} diff --git a/v2/src/main.rs b/v2/src/main.rs new file mode 100644 index 0000000..9df3cb0 --- /dev/null +++ b/v2/src/main.rs @@ -0,0 +1,5 @@ +mod data_struct; + +fn main() { + println!("Hello, world!"); +}