use std::collections::HashMap; use shared::model::InputFetchMethod; use crate::model::{ConfigInput, StagedInput}; #[derive(Clone, Debug)] pub struct InputSource { pub url: String, pub username: Option, pub password: Option, pub method: InputFetchMethod, pub headers: HashMap, } impl InputSource { pub fn with_url(&self, url: String) -> Self { Self { url, username: self.username.clone(), password: self.password.clone(), method: self.method, headers: self.headers.clone(), } } } macro_rules! impl_input_source_from { ($input_type:ty) => { impl From<&$input_type> for InputSource { fn from(input: &$input_type) -> Self { Self { url: input.url.clone(), username: input.username.clone(), password: input.password.clone(), method: input.method, headers: input.headers.clone(), } } } }; } impl_input_source_from!(ConfigInput); impl_input_source_from!(StagedInput);