Skip to content
Snippets Groups Projects
Verified Commit c96b272e authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Make `get_or_error` generic

Thanks to Andreu Botella!
parent c4fd3260
No related branches found
No related tags found
No related merge requests found
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
use serde::de::Deserialize; use serde::de::Deserialize;
use pamsm::PamError;
use libnss::interop::Response;
extern crate config; extern crate config;
const DEFAULT_CONFIG_FILE: &str = "/etc/nss_pam_oidc"; const DEFAULT_CONFIG_FILE: &str = "/etc/nss_pam_oidc";
...@@ -73,12 +70,7 @@ pub fn get_optional<'de, T: Deserialize<'de>>(conf: &config::Config, key: &str) ...@@ -73,12 +70,7 @@ pub fn get_optional<'de, T: Deserialize<'de>>(conf: &config::Config, key: &str)
} }
} }
enum DesiredError { pub fn get_or_error<'de, T: Deserialize<'de>, E>(config: &config::Config, key: &str, error_value: E) -> Result<T, E> {
Response,
PamError
}
pub fn get_or_error<'de, T: Deserialize<'de>>(config: &config::Config, key: &str, error_value: DesiredError) -> Result<T, Response> {
match get_optional(config, key) { match get_optional(config, key) {
Some(v) => { Some(v) => {
debug!("Configuration key found: {}", key); debug!("Configuration key found: {}", key);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment