syntect/highlighting/
settings.rs
1use plist::Error as PlistError;
4use std::io::{Read, Seek};
5
6pub use serde_json::Value as Settings;
7
8pub trait ParseSettings: Sized {
9 type Error;
10 fn parse_settings(settings: Settings) -> Result<Self, Self::Error>;
11}
12
13#[derive(Debug, thiserror::Error)]
15#[non_exhaustive]
16pub enum SettingsError {
17 #[error("Incorrect Plist syntax: {0}")]
19 Plist(PlistError),
20}
21
22impl From<PlistError> for SettingsError {
23 fn from(error: PlistError) -> SettingsError {
24 SettingsError::Plist(error)
25 }
26}
27
28pub fn read_plist<R: Read + Seek>(reader: R) -> Result<Settings, SettingsError> {
29 let settings = plist::from_reader(reader)?;
30 Ok(settings)
31}