Skip to content

Commit

Permalink
move vanilla registry to registry crate
Browse files Browse the repository at this point in the history
  • Loading branch information
JieningYu committed Feb 1, 2024
1 parent 73bb53f commit 7e524b1
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
17 changes: 17 additions & 0 deletions util/fmt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "rimecraft-fmt"
version = "0.1.0"
edition = "2021"
authors = ["JieningYu <[email protected]>"]
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
Empty file added util/fmt/src/lib.rs
Empty file.
2 changes: 0 additions & 2 deletions util/identifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions util/registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions util/registry/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ pub mod edcode {
}
}

/// Serde wrapper for registry reference keys.
#[derive(Debug, Clone, Copy)]
pub struct RegRef<T>(pub T);

Expand Down
19 changes: 19 additions & 0 deletions util/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,14 @@ pub mod edcode {

use crate::{ProvideRegistry, Reg};

/// Error type for `edcode` support.
#[derive(Debug)]
pub enum Error<K> {
/// Error for invalid key.
InvalidKey(K),
/// Error for invalid raw id.
InvalidRawId(usize),
/// Error for `VarI32`.
VarI32(VarI32TooBigError),
}

Expand Down Expand Up @@ -619,3 +623,18 @@ pub mod edcode {

#[allow(dead_code)]
type BoxedError = Box<dyn std::error::Error + Send + Sync>;

#[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<T> = Registry<rimecraft_identifier::vanilla::Identifier, T>;

0 comments on commit 7e524b1

Please sign in to comment.