conf::data_types: minor style and error msg fixups

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/487/head
Manos Pitsidianakis 1 month ago
parent ba3ad8ed18
commit d0c81749ee
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -43,6 +43,7 @@ impl DotAddressable for bool {}
impl DotAddressable for String {}
impl DotAddressable for char {}
impl DotAddressable for data_types::IndexStyle {}
impl DotAddressable for data_types::SearchBackend {}
impl DotAddressable for u64 {}
impl DotAddressable for TagHash {}
impl DotAddressable for crate::terminal::Color {}
@ -54,7 +55,6 @@ impl DotAddressable for melib::LogLevel {}
impl DotAddressable for PathBuf {}
impl DotAddressable for ToggleFlag {}
impl DotAddressable for ActionFlag {}
impl DotAddressable for data_types::SearchBackend {}
impl DotAddressable for melib::SpecialUsageMailbox {}
impl<T: DotAddressable> DotAddressable for Option<T> {}
impl<T: DotAddressable> DotAddressable for Vec<T> {}

@ -41,11 +41,16 @@ impl<'de> Deserialize<'de> for IndexStyle {
{
let s = <String>::deserialize(deserializer)?;
match s.as_str() {
"Plain" | "plain" => Ok(Self::Plain),
"Threaded" | "threaded" => Ok(Self::Threaded),
"Compact" | "compact" => Ok(Self::Compact),
"Conversations" | "conversations" => Ok(Self::Conversations),
_ => Err(de::Error::custom("invalid `index_style` value")),
plain if plain.eq_ignore_ascii_case("plain") => Ok(Self::Plain),
threaded if threaded.eq_ignore_ascii_case("threaded") => Ok(Self::Threaded),
compact if compact.eq_ignore_ascii_case("compact") => Ok(Self::Compact),
conversations if conversations.eq_ignore_ascii_case("conversations") => {
Ok(Self::Conversations)
}
_ => Err(de::Error::custom(
"invalid `index_style` value, expected one of: \"plain\", \"threaded\", \
\"compact\" or \"conversations\".",
)),
}
}
}
@ -94,7 +99,12 @@ impl<'de> Deserialize<'de> for SearchBackend {
Ok(Self::None)
}
auto if auto.eq_ignore_ascii_case("auto") => Ok(Self::Auto),
_ => Err(de::Error::custom("invalid `search_backend` value")),
_ => Err(de::Error::custom(if cfg!(feature = "sqlite3") {
"invalid `search_backend` value, expected one of: \"sqlite3\", \"sqlite\", \
\"none\" or \"auto\"."
} else {
"invalid `search_backend` value, expected one of: \"none\" or \"auto\"."
})),
}
}
}

Loading…
Cancel
Save