From 7e524b1a0c2767fa571a67e561a73eda46c4d75e Mon Sep 17 00:00:00 2001 From: JieningYu Date: Thu, 1 Feb 2024 10:13:38 +0800 Subject: [PATCH] move vanilla registry to registry crate --- util/fmt/Cargo.toml | 17 +++++++++++++++++ util/fmt/src/lib.rs | 0 util/identifier/Cargo.toml | 2 -- util/registry/Cargo.toml | 4 ++++ util/registry/src/key.rs | 1 + util/registry/src/lib.rs | 19 +++++++++++++++++++ 6 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 util/fmt/Cargo.toml create mode 100644 util/fmt/src/lib.rs diff --git a/util/fmt/Cargo.toml b/util/fmt/Cargo.toml new file mode 100644 index 0000000..26321bc --- /dev/null +++ b/util/fmt/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "rimecraft-fmt" +version = "0.1.0" +edition = "2021" +authors = ["JieningYu "] +description = "Minecraft formattings" +repository = "https://github.com/rimecraft-rs/rimecraft/" +license = "AGPL-3.0-or-later" +categories = [] + +[badges] +maintenance = { status = "passively-maintained" } + +[dependencies] + +[lints] +workspace = true diff --git a/util/fmt/src/lib.rs b/util/fmt/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/util/identifier/Cargo.toml b/util/identifier/Cargo.toml index 43be92f..c0aa0b4 100644 --- a/util/identifier/Cargo.toml +++ b/util/identifier/Cargo.toml @@ -14,13 +14,11 @@ maintenance = { status = "passively-maintained" } [dependencies] serde = { version = "1.0", optional = true } rimecraft-edcode = { path = "../edcode", optional = true } -rimecraft-registry = { path = "../registry", optional = true } [features] serde = ["dep:serde"] edcode = ["dep:rimecraft-edcode"] vanilla = [] -vanilla-registry = ["vanilla", "dep:rimecraft-registry"] [lints] workspace = true diff --git a/util/registry/Cargo.toml b/util/registry/Cargo.toml index 16cd19c..2de3f8a 100644 --- a/util/registry/Cargo.toml +++ b/util/registry/Cargo.toml @@ -15,10 +15,14 @@ maintenance = { status = "passively-maintained" } parking_lot = "0.12" serde = { version = "1.0", optional = true } rimecraft-edcode = { path = "../edcode", optional = true } +rimecraft-identifier = { path = "../identifier", optional = true, features = [ + "vanilla", +] } [features] serde = ["dep:serde"] edcode = ["dep:rimecraft-edcode"] +vanilla-identifier = ["dep:rimecraft-identifier"] [lints] workspace = true diff --git a/util/registry/src/key.rs b/util/registry/src/key.rs index 7b6c708..3dc8eca 100644 --- a/util/registry/src/key.rs +++ b/util/registry/src/key.rs @@ -180,6 +180,7 @@ pub mod edcode { } } + /// Serde wrapper for registry reference keys. #[derive(Debug, Clone, Copy)] pub struct RegRef(pub T); diff --git a/util/registry/src/lib.rs b/util/registry/src/lib.rs index 17716eb..c2da1a1 100644 --- a/util/registry/src/lib.rs +++ b/util/registry/src/lib.rs @@ -553,10 +553,14 @@ pub mod edcode { use crate::{ProvideRegistry, Reg}; + /// Error type for `edcode` support. #[derive(Debug)] pub enum Error { + /// Error for invalid key. InvalidKey(K), + /// Error for invalid raw id. InvalidRawId(usize), + /// Error for `VarI32`. VarI32(VarI32TooBigError), } @@ -619,3 +623,18 @@ pub mod edcode { #[allow(dead_code)] type BoxedError = Box; + +#[cfg(feature = "vanilla-identifier")] +impl crate::key::Root for rimecraft_identifier::vanilla::Identifier { + #[inline] + fn root() -> Self { + Self::new( + Default::default(), + rimecraft_identifier::vanilla::Path::new_unchecked("root"), + ) + } +} + +#[cfg(feature = "vanilla-registry")] +#[doc("Registry using vanilla `Identifier`.")] +pub type VanillaRegistry = Registry;