33 lines
1.0 KiB
Rust
33 lines
1.0 KiB
Rust
use std::path::Path;
|
|
|
|
use serde::Deserialize;
|
|
use crate::errors::AutoDecryptError;
|
|
use crate::services::providers::ConsentMethode;
|
|
use crate::services::providers::ActionType;
|
|
use crate::services::providers::Providers;
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub (super) struct TomlProviders {
|
|
pub(crate) access_key_hash: Option<String>,
|
|
pub(crate) execution_action: ActionType,
|
|
pub(crate) consent_methode: Option<ConsentMethode>,
|
|
}
|
|
|
|
|
|
|
|
impl TomlProviders {
|
|
pub(super) fn to_internal(mut self, base_config_dir: &Path) -> Result<Providers, AutoDecryptError> {
|
|
if let ActionType::EncryptedRequest(ref mut action_type) = self.execution_action {
|
|
if action_type.content.is_none() {
|
|
action_type.load_from_file(base_config_dir)?;
|
|
}
|
|
}
|
|
|
|
Ok(Providers {
|
|
access_key_hash: self.access_key_hash.unwrap_or("".to_string()),
|
|
consent_methode: self.consent_methode.unwrap_or(ConsentMethode::None),
|
|
execution_action: self.execution_action,
|
|
})
|
|
}
|
|
}
|