summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-09-26 12:52:37 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-10-02 20:40:36 +0200
commit7485f27059a6bccf4bbecf695c76fbda82da48d3 (patch)
tree3966b3a0b4b02b108460fa2e2d254a84b2e265c5 /src
parent052c9503c65ee66074d00e8885aa13e6831bf079 (diff)
Remove support for hjson
The serde-hjson crate is not maintained anymore and this feature is actually causing pain in packaging even. Thus, remove it. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r--src/file/format/hjson.rs54
-rw-r--r--src/file/format/mod.rs13
-rw-r--r--src/lib.rs5
3 files changed, 1 insertions, 71 deletions
diff --git a/src/file/format/hjson.rs b/src/file/format/hjson.rs
deleted file mode 100644
index 4b76114..0000000
--- a/src/file/format/hjson.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-use std::error::Error;
-
-use crate::map::Map;
-use crate::value::{Value, ValueKind};
-
-pub fn parse(
- uri: Option<&String>,
- text: &str,
-) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>> {
- // Parse a JSON object value from the text
- // TODO: Have a proper error fire if the root of a file is ever not a Table
- let value = from_hjson_value(uri, &serde_hjson::from_str(text)?);
- match value.kind {
- ValueKind::Table(map) => Ok(map),
-
- _ => Ok(Map::new()),
- }
-}
-
-fn from_hjson_value(uri: Option<&String>, value: &serde_hjson::Value) -> Value {
- match *value {
- serde_hjson::Value::String(ref value) => Value::new(uri, ValueKind::String(value.clone())),
-
- serde_hjson::Value::I64(value) => Value::new(uri, ValueKind::Integer(value)),
-
- serde_hjson::Value::U64(value) => Value::new(uri, ValueKind::Integer(value as i64)),
-
- serde_hjson::Value::F64(value) => Value::new(uri, ValueKind::Float(value)),
-
- serde_hjson::Value::Bool(value) => Value::new(uri, ValueKind::Boolean(value)),
-
- serde_hjson::Value::Object(ref table) => {
- let mut m = Map::new();
-
- for (key, value) in table {
- m.insert(key.clone(), from_hjson_value(uri, value));
- }
-
- Value::new(uri, ValueKind::Table(m))
- }
-
- serde_hjson::Value::Array(ref array) => {
- let mut l = Vec::new();
-
- for value in array {
- l.push(from_hjson_value(uri, value));
- }
-
- Value::new(uri, ValueKind::Array(l))
- }
-
- serde_hjson::Value::Null => Value::new(uri, ValueKind::Nil),
- }
-}
diff --git a/src/file/format/mod.rs b/src/file/format/mod.rs
index 9f6d7d7..b4129e1 100644
--- a/src/file/format/mod.rs
+++ b/src/file/format/mod.rs
@@ -17,9 +17,6 @@ mod json;
#[cfg(feature = "yaml")]
mod yaml;
-#[cfg(feature = "hjson")]
-mod hjson;
-
#[cfg(feature = "ini")]
mod ini;
@@ -43,10 +40,6 @@ pub enum FileFormat {
#[cfg(feature = "yaml")]
Yaml,
- /// HJSON (parsed with serde_hjson)
- #[cfg(feature = "hjson")]
- Hjson,
-
/// INI (parsed with rust_ini)
#[cfg(feature = "ini")]
Ini,
@@ -75,9 +68,6 @@ lazy_static! {
#[cfg(feature = "yaml")]
formats.insert(FileFormat::Yaml, vec!["yaml", "yml"]);
- #[cfg(feature = "hjson")]
- formats.insert(FileFormat::Hjson, vec!["hjson"]);
-
#[cfg(feature = "ini")]
formats.insert(FileFormat::Ini, vec!["ini"]);
@@ -119,9 +109,6 @@ impl FileFormat {
#[cfg(feature = "yaml")]
FileFormat::Yaml => yaml::parse(uri, text),
- #[cfg(feature = "hjson")]
- FileFormat::Hjson => hjson::parse(uri, text),
-
#[cfg(feature = "ini")]
FileFormat::Ini => ini::parse(uri, text),
diff --git a/src/lib.rs b/src/lib.rs
index 267e0d8..98c90b4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,7 +6,7 @@
//! - Environment variables
//! - Another Config instance
//! - Remote configuration: etcd, Consul
-//! - Files: TOML, JSON, YAML, HJSON, INI, RON, JSON5
+//! - Files: TOML, JSON, YAML, INI, RON, JSON5
//! - Manual, programmatic override (via a `.set` method on the Config instance)
//!
//! Additionally, Config supports:
@@ -41,9 +41,6 @@ extern crate serde_json;
#[cfg(feature = "yaml")]
extern crate yaml_rust;
-#[cfg(feature = "hjson")]
-extern crate serde_hjson;
-
#[cfg(feature = "ini")]
extern crate ini;