From c63cd1f11a4b1cc830b46e0a9d0d28f96400d17b Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Tue, 21 Jun 2022 07:56:21 -0400 Subject: [PATCH 1/2] Allows you to remove the minecraft-data at compile time --- Cargo.toml | 11 ++++++++--- README.md | 5 +++++ src/lib.rs | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ff562a8..6a5c01a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,11 @@ thiserror = "1.0.31" serde_json = "1.0.81" serde_derive = "1.0.137" serde = "1.0.137" -include_dir = "0.7.2" -itertools = "0.10.3" -lazy_static = "1.4.0" +include_dir = { version = "0.7.2", optional = true } +itertools = { version = "0.10.3", optional = true } +lazy_static = { version = "1.4.0", optional = true } + +[features] +default = ["include_data"] +include_data = ["include_dir", "itertools", "lazy_static"] + diff --git a/README.md b/README.md index c556095..bdace3a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,11 @@ This repository is a rust library to access minecraft data. The data itself hosted in the [minecraft-data](https://github.com/PrismarineJS/minecraft-data) repository and included into the library at compile time. + +### Excluding the minecraft-data at compile time +By adding `default-features=false` to the dependency in your `Cargo.toml` file, you can exclude the minecraft-data from the library. + + ## Usage ```rust diff --git a/src/lib.rs b/src/lib.rs index 10bc226..c28e616 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,12 +4,15 @@ extern crate serde_derive; /// Provides data access methods +#[cfg(feature="include_data")] pub mod api; +#[cfg(feature="include_data")] pub(crate) mod data; /// Contains the type definitions for the data pub mod models; pub(crate) mod utils; +#[cfg(feature="include_data")] pub use api::Api; pub use utils::error::DataError; pub use utils::error::DataResult; From 47e95167ef29b0cf0c4034da6daddf675b1ef590 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Tue, 21 Jun 2022 09:59:16 -0400 Subject: [PATCH 2/2] Rename the feature --- Cargo.toml | 4 ++-- src/lib.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6a5c01a..6be4001 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,6 @@ itertools = { version = "0.10.3", optional = true } lazy_static = { version = "1.4.0", optional = true } [features] -default = ["include_data"] -include_data = ["include_dir", "itertools", "lazy_static"] +default = ["include-data"] +include-data = ["include_dir", "itertools", "lazy_static"] diff --git a/src/lib.rs b/src/lib.rs index c28e616..4fa7420 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,15 +4,15 @@ extern crate serde_derive; /// Provides data access methods -#[cfg(feature="include_data")] +#[cfg(feature="include-data")] pub mod api; -#[cfg(feature="include_data")] +#[cfg(feature="include-data")] pub(crate) mod data; /// Contains the type definitions for the data pub mod models; pub(crate) mod utils; -#[cfg(feature="include_data")] +#[cfg(feature="include-data")] pub use api::Api; pub use utils::error::DataError; pub use utils::error::DataResult;