You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.9 KiB
53 lines
1.9 KiB
From f4aa3a1421d4213f8611af8bc243f2dcdf86146f Mon Sep 17 00:00:00 2001
|
|
From: Robin Stocker <rstocker@atlassian.com>
|
|
Date: Thu, 28 Jun 2018 12:50:41 +1000
|
|
Subject: [PATCH] Upgrade plist to 0.3 and take advantage of serde integration
|
|
|
|
---
|
|
src/highlighting/settings.rs | 24 ++++--------------------
|
|
1 file changed, 4 insertions(+), 20 deletions(-)
|
|
|
|
diff --git a/src/highlighting/settings.rs b/src/highlighting/settings.rs
|
|
index d0e7be7..da64fcf 100644
|
|
--- a/src/highlighting/settings.rs
|
|
+++ b/src/highlighting/settings.rs
|
|
@@ -2,8 +2,8 @@
|
|
/// released under the MIT license by @defuz
|
|
|
|
use std::io::{Read, Seek};
|
|
-use plist::{Plist, Error as PlistError};
|
|
-use serde_json::Number;
|
|
+use plist::{Error as PlistError};
|
|
+use plist::serde::deserialize;
|
|
|
|
pub use serde_json::Value as Settings;
|
|
pub use serde_json::Value::Array as SettingsArray;
|
|
@@ -33,22 +33,6 @@ impl From<PlistError> for SettingsError {
|
|
}
|
|
|
|
pub fn read_plist<R: Read + Seek>(reader: R) -> Result<Settings, SettingsError> {
|
|
- let plist = Plist::read(reader)?;
|
|
- Ok(to_json(plist))
|
|
-}
|
|
-
|
|
-fn to_json(plist: Plist) -> Settings {
|
|
- match plist {
|
|
- Plist::Array(elements) =>
|
|
- SettingsArray(elements.into_iter().map(to_json).collect()),
|
|
- Plist::Dictionary(entries) =>
|
|
- SettingsObject(entries.into_iter().map(|(k, v)| (k, to_json(v))).collect()),
|
|
- Plist::Boolean(value) => Settings::Bool(value),
|
|
- Plist::Data(bytes) => Settings::Array(bytes.into_iter().map(|b| b.into()).collect()),
|
|
- Plist::Date(value) => Settings::String(value.to_string()),
|
|
- Plist::Real(value) =>
|
|
- Settings::Number(Number::from_f64(value).expect("Error converting plist real value to JSON number")),
|
|
- Plist::Integer(value) => Settings::Number(value.into()),
|
|
- Plist::String(s) => Settings::String(s),
|
|
- }
|
|
+ let settings = deserialize(reader)?;
|
|
+ Ok(settings)
|
|
}
|
|
--
|
|
2.19.0.rc1
|
|
|