conf.rs: reject unknown configuration options

Closes #11
memfd
Manos Pitsidianakis 2020-08-03 22:53:06 +03:00
parent 750e32c8e1
commit 52bcecfd4a
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
12 changed files with 22 additions and 1 deletions

View File

@ -134,6 +134,7 @@ use super::*;
let literal_struct = quote! {
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct #override_ident {
#(#field_tokentrees),*
}

View File

@ -108,6 +108,7 @@ macro_rules! mailbox_settings {
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MailUIConf {
#[serde(default)]
pub pager: PagerSettingsOverride,
@ -191,6 +192,7 @@ impl FileAccount {
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct FileSettings {
pub accounts: HashMap<String, FileAccount>,
#[serde(default)]
@ -821,6 +823,7 @@ mod pp {
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct LogSettings {
#[serde(default)]
log_file: Option<PathBuf>,

View File

@ -25,6 +25,7 @@ use std::collections::HashMap;
/// Settings for writing and sending new e-mail
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct ComposingSettings {
/// A command to pipe new emails to
/// Required

View File

@ -25,6 +25,7 @@ use melib::{MeliError, Result};
/// Settings for mail listings
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ListingSettings {
/// Number of context lines when going to next page.
/// Default: 0

View File

@ -23,6 +23,7 @@ use super::default_vals::{internal_value_false, none};
/// Settings for the notifications function.
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct NotificationsSettings {
/// A command to pipe notifications through
/// Default: None

View File

@ -23,6 +23,7 @@
use super::*;
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct PagerSettingsOverride {
#[doc = " Number of context lines when going to next page."]
#[doc = " Default: 0"]
@ -94,6 +95,7 @@ impl Default for PagerSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct ListingSettingsOverride {
#[doc = " Number of context lines when going to next page."]
#[doc = " Default: 0"]
@ -131,6 +133,7 @@ impl Default for ListingSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct NotificationsSettingsOverride {
#[doc = " A command to pipe notifications through"]
#[doc = " Default: None"]
@ -161,6 +164,7 @@ impl Default for NotificationsSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct ShortcutsOverride {
#[serde(default)]
pub general: Option<GeneralShortcuts>,
@ -199,6 +203,7 @@ impl Default for ShortcutsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct ComposingSettingsOverride {
#[doc = " A command to pipe new emails to"]
#[doc = " Required"]
@ -235,6 +240,7 @@ impl Default for ComposingSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct TagsSettingsOverride {
#[serde(deserialize_with = "tag_color_de")]
#[serde(default)]
@ -253,6 +259,7 @@ impl Default for TagsSettingsOverride {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct PGPSettingsOverride {
#[doc = " auto verify signed e-mail according to RFC3156"]
#[serde(alias = "auto-verify-signatures")]

View File

@ -28,6 +28,7 @@ use melib::{MeliError, Result, ToggleFlag};
/// Settings for the pager function.
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct PagerSettings {
/// Number of context lines when going to next page.
/// Default: 0

View File

@ -23,6 +23,7 @@ use super::default_vals::*;
/// Settings for digital signing and encryption
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct PGPSettings {
/// auto verify signed e-mail according to RFC3156
#[serde(default = "true_val", alias = "auto-verify-signatures")]

View File

@ -35,6 +35,7 @@ macro_rules! shortcut {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Shortcuts {
#[serde(default)]
pub general: GeneralShortcuts,

View File

@ -29,6 +29,7 @@ use std::collections::{hash_map::DefaultHasher, HashMap, HashSet};
use std::hash::Hasher;
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct TagsSettings {
#[serde(default, deserialize_with = "tag_color_de")]
pub colors: HashMap<u64, Color>,

View File

@ -28,7 +28,7 @@ use melib::{MeliError, Result, ToggleFlag};
/// Settings for terminal display
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(default)]
#[serde(default, deny_unknown_fields)]
pub struct TerminalSettings {
/// light, dark
pub theme: String,

View File

@ -306,6 +306,7 @@ const DEFAULT_KEYS: &[&str] = &[
/// `ThemeAttributeInner` but with the links resolved.
#[derive(Debug, PartialEq, Eq, Clone, Default, Copy, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ThemeAttribute {
pub fg: Color,
pub bg: Color,
@ -314,6 +315,7 @@ pub struct ThemeAttribute {
/// Holds {fore,back}ground color and terminal attribute values.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ThemeAttributeInner {
#[serde(default)]
fg: ThemeValue<Color>,
@ -799,6 +801,7 @@ impl<'de> Deserialize<'de> for Themes {
rest: ThemeAttributeInnerOptions,
}
#[derive(Deserialize, Default)]
#[serde(deny_unknown_fields)]
struct ThemeAttributeInnerOptions {
#[serde(default)]
fg: Option<ThemeValue<Color>>,